我将PySide的一个下载副本从其原始安装位置(/Library/PySide/2.7/site-packages/PySide)移动到网络上的一个位置,因此脚本可以访问它。但是,我开始得到“库未加载”错误。我在我的桌面上制作的拷贝来进行测试:图书馆OSX上的PySide没有加载错误
Traceback (most recent call last):
File "test_pyside_imports.py", line 2, in <module>
import PySide.QtCore
ImportError: dlopen(/Users/user/Desktop/PySide_OSX/PySide/QtCore.so, 2): Library not loaded: /Library/Python/2.7/site-packages/PySide/libpyside-python2.7.1.2.dylib
Referenced from: /Users/user/Desktop/PySide_OSX/PySide/QtCore.so
Reason: image not found
我也碰到这个问题之前运行,而且我相信,我有一个bash脚本,刚跑install_name_tool很多固定它:
#! /usr/bin/env bash
install_name_tool -change @rpath/libpyside-python2.7.1.2.dylib ./PySide/libpyside-python2.7.1.2.dylib ./PySide/QtCore.so
install_name_tool -change @rpath/libshiboken-python2.7.1.2.dylib ./PySide/libshiboken-python2.7.1.2.dylib ./PySide/QtCore.so
但是,由于某些原因,脚本似乎无法解决问题,并且QtCore.so仍在寻找原始位置的库。我检查了这些文件的权限,并在脚本中重复检查了路径。任何想法我缺少什么?
谢谢。
编辑
越来越近。
#! /usr/bin/env bash
install_name_tool -change /Library/Python/2.7/site-packages/PySide/libpyside-python2.7.1.2.dylib ./PySide/libpyside-python2.7.1.2.dylib ./PySide/QtCore.so
install_name_tool -change /Library/Python/2.7/site-packages/PySide/libshiboken-python2.7.1.2.dylib ./PySide/libshiboken-python2.7.1.2.dylib ./PySide/QtCore.so
当我运行上面的bash脚本,然后尝试做进口,我得到一个新的错误:
D25MG1AZF8J8:PySide_OSX spearsc$ python test_pyside_imports.py
Traceback (most recent call last):
File "test_pyside_imports.py", line 2, in <module>
import PySide.QtCore
ImportError: dlopen(/Users/spearsc/Desktop/PySide_OSX/PySide/QtCore.so, 2): Library not loaded: ./PySide/libpyside-python2.7.1.2.dylib
Referenced from: /Users/spearsc/Desktop/PySide_OSX/PySide/QtCore.so
Reason: unsafe use of relative rpath ./PySide/libpyside-python2.7.1.2.dylib in /Users/spearsc/Desktop/PySide_OSX/PySide/QtCore.so with restricted binary
我想用我的第一个bash脚本的问题是,老路径不存在并被忽略。现在,我需要再次尝试,但使用绝对路径。