我正在尝试使用应用程序随附的Houdini Python模块,该模块是Houdini安装文件夹的一部分,位于标准Python路径之外。遵循安装说明后,运行Houdini Terminal 16.5.571脚本并将/Applications/Houdini/Houdini16.5.571/Frameworks/Houdini.framework/Versions/Current/Resources/houdini/python2.7libs
添加到_virtualenv_path_extensions.pth
文件夹中的site-packages
中,可以导入hou
模块,即Python部分。但是,它无法加载动态库。
错误信息
Traceback (most recent call last):
File "myscript.py", line 7, in <module>
import hou
File "/Applications/Houdini/Houdini16.5.571/Frameworks/Houdini.framework/Versions/Current/Resources/houdini/python2.7libs/hou.py", line 19, in <module>
import _hou
ImportError: dlopen(/Applications/Houdini/Houdini16.5.571/Frameworks/Houdini.framework/Versions/Current/Resources/houdini/python2.7libs/_hou.so, 2): Library not loaded: @rpath/Houdini.framework/Versions/16.5.571/Houdini
Referenced from: /Applications/Houdini/Houdini16.5.571/Frameworks/Houdini.framework/Versions/Current/Resources/houdini/python2.7libs/_hou.so
Reason: image not found
错误消息中提到的所有文件和文件夹都位于Houdini路径
/Applications/Houdini/Houdini16.5.571/Frameworks/Houdini.framework/Versions/Current
中,其中Current
是指向16.5.571
的符号链接。Python模块
Resources/houdini/python2.7libs/hou.py
找到了Python模块。
共享库
Resources/houdini/python2.7libs/_hou.so`
它包含对
@rpath/Houdini.framework/Versions/16.5.571/Houdini
的引用,该引用可能正在尝试查找。Houdini
这似乎链接到实际的
dylib
文件,其中包含@loader_path/Libraries
和dylib...@rpath/libHoudiniUI
等以及许多其他文件。我在这里Cannot find dynamic library when running a Python script from Bazel读到SIP可能是导致此错误的原因,但是即使将
ln -s
共享库转换成/usr/local/lib
后,仍然会发生错误。我正在使用
pyenv
,但在系统Python环境中进行了尝试,导致了相同的行为。有什么建议么?
最佳答案
dyld: Library not loaded ... Reason: Image not loaded中的答案为我指明了正确的方向,建议使用otool
重写动态库路径。
列出_hou.so
加载的所有库,显示以下列表,其中@rpath/Houdini.framework/Versions/16.5.571/Houdini
是导致此问题的一个。
otool -L /Applications/Houdini/Houdini16.5.571/Frameworks/Houdini.framework/Versions/Current/Resources/houdini/python2.7libs/_hou.so
/Applications/Houdini/Houdini16.5.571/Frameworks/Houdini.framework/Versions/Current/Resources/houdini/python2.7libs/_hou.so:
@rpath/Houdini.framework/Versions/16.5.571/Houdini (compatibility version 1.0.0, current version 16.5.255)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1443.14.0)
/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 22.0.0)
/System/Library/Frameworks/QTKit.framework/Versions/A/QTKit (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 492.0.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
可以使用
install_name_tool -change
重写路径。install_name_tool -change @rpath/Houdini.framework/Versions/16.5.571/Houdini /Applications/Houdini/Houdini16.5.571/Frameworks/Houdini.framework/Versions/16.5.571/Houdini /Applications/Houdini/Houdini16.5.571/Frameworks/Houdini.framework/Versions/Current/Resources/houdini/python2.7libs/_hou.so
最好使用相对路径。