Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/349.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将libgphoto2.dylib加载到python时出现问题_Python_Macos_Camera_Ctypes_Libgphoto2 - Fatal编程技术网

将libgphoto2.dylib加载到python时出现问题

将libgphoto2.dylib加载到python时出现问题,python,macos,camera,ctypes,libgphoto2,Python,Macos,Camera,Ctypes,Libgphoto2,我已经正确安装了gphoto,我可以使用相机的所有功能,但出于某些原因 gphoto = ctypes.CDLL('libgphoto2.dylib') 抛出一个错误 $ python Python 2.7.5 (default, Aug 25 2013, 00:04:04) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type "help", "copyright", "credits" or "lice

我已经正确安装了gphoto,我可以使用相机的所有功能,但出于某些原因

gphoto = ctypes.CDLL('libgphoto2.dylib')
抛出一个错误

$ python
Python 2.7.5 (default, Aug 25 2013, 00:04:04) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> gphoto = ctypes.CDLL('libgphoto2.dylib')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(libgphoto2.dylib, 6): image not found
>>> 

所以我不明白为什么gphoto2可以使用libgphoto2,而ctypes不能。有什么建议吗?我对这个很陌生,所以这可能是一个非常基本、愚蠢的错误

find_library
不输出任何内容,只在shell中给我一行新行,不管我是给它
gphoto2
还是
libgphoto2.dylib
还是其他任何内容……谢谢您的评论
otool-L
表示它将“显示对象文件使用的共享库的名称和版本号,以及共享库ID(如果文件是共享库)。”但是当我以
$otool-L libgphoto2.dylib
$otool-L gphoto2
$otool-L libgphoto2
运行它时,我只得到
错误:/Applications/Xcode.app/Contents/Developer/toolschains/XcodeDefault.xtoolchain/usr/bin/otool:无法打开文件:gphoto(没有这样的文件或目录)
您需要为它提供gphoto2的完整路径。用
哪个gphoto2找到它
。我还没有完全测试过,但是基于
>导入ctypes>>>gphoto=ctypes.CDLL('/opt/local/lib/libgphoto2.6.dylib')>>>>
我认为它会工作的!非常感谢你!