1

我正在尝试使用应用程序附带的 Houdini Python 模块,它是标准 Python 路径之外的 Houdini 安装文件夹的一部分。按照安装说明运行后,运行Houdini Terminal 16.5.571脚本并在我的文件夹中添加可以导入的/Applications/Houdini/Houdini16.5.571/Frameworks/Houdini.framework/Versions/Current/Resources/houdini/python2.7libs模块,即 Python 部分。但是它无法加载动态库。_virtualenv_path_extensions.pthsite-packageshou

错误信息

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/Librariesdylib...@rpath/libHoudiniUI以及许多其他文件。

我在这里读到从 Bazel 运行 Python 脚本时找不到动态库,SIP 可能会导致它,但即使在ln -s共享库进入/usr/local/lib错误之后仍然发生。

我正在使用pyenv但尝试使用系统 Python 环境,导致相同的行为。

有什么建议么?

4

1 回答 1

1

dyld中的答案:未加载库...原因:未加载图像为我指明了正确的方向,建议使用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

使用相对路径可能会更好。

于 2018-09-27T23:22:24.327 回答