[New-bugs-announce] [issue43964] ctypes CDLL search path issue on MacOS

Victor Lazzarini report at bugs.python.org
Wed Apr 28 04:39:49 EDT 2021


New submission from Victor Lazzarini <Victor.Lazzarini at nuim.ie>:

With Python 3.9.4 ctypes.CDLL does not appear to find framework libraries installed in /Library/Frameworks.

--- With Python 3.6.5:

victor at MacBook-Pro ~ % python3                                         
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 03:03:55) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.CDLL('CUDA.framework/CUDA')
<CDLL 'CUDA.framework/CUDA', handle 102b044b0 at 0x102c9b9e8>
>>> 

--- With Python 3.9.4

victor at MacBook-Pro ~ % python3.9
Python 3.9.4 (v3.9.4:1f2e3088f3, Apr  4 2021, 12:32:44) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.CDLL('CUDA.framework/CUDA')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(CUDA.framework/CUDA, 6): image not found
>>> 

This happens with all frameworks I have installed in /Library/Frameworks.
The full path seems to work OK:

>>> ctypes.CDLL('/Library/Frameworks/CUDA.framework/CUDA')
<CDLL '/Library/Frameworks/CUDA.framework/CUDA', handle 7fa358404180 at 0x7fa3580eeaf0>
>>> 

but that's suboptimal as in MacOS you might have frameworks installed elsewhere.

----------
components: macOS
messages: 392173
nosy: Victor.Lazzarini, ned.deily, ronaldoussoren
priority: normal
severity: normal
status: open
title: ctypes CDLL search path issue on MacOS
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43964>
_______________________________________


More information about the New-bugs-announce mailing list