未找到mac OS PyQt5图像

时间:2016-11-27 00:13:29

标签: python macos qt path pyqt

我正在尝试在macOS Sierra上安装PyQt5。我成功安装qt-unified-mac-x64-2.0.3-online比使用pip3 install pyqt5安装PyQt。 我的$ PYTHONPATH是/usr/local/lib/python3.5/site-packages:

当我尝试运行基本的Qt应用

import sys
from PyQt5 import QtCore, QtGui, uic

qtCreatorFile = "dialog.ui" # Enter file here.

Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile)

class MyApp(QtGui.QMainWindow, Ui_MainWindow):
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        Ui_MainWindow.__init__(self)
        self.setupUi(self)

if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    window = MyApp()
    window.show()
    sys.exit(app.exec_())

我收到错误

Traceback (most recent call last):
  File "test.py", line 2, in <module>
    from PyQt5 import QtCore, QtGui, uic
ImportError: dlopen(/usr/local/lib/python3.5/site-packages/PyQt5/QtCore.so, 2): Library not loaded: @rpath/QtCore.framework/Versions/5/QtCore
  Referenced from: /usr/local/lib/python3.5/site-packages/PyQt5/QtCore.so
  Reason: image not found

我已经用Google搜索并找到了一些解决方案,但没有任何效果(或者我现在太累了X_X)

编辑: 我试着安装到python2.x但我有同样的问题。 谢谢你的帮助。

解决 我将PATH直接插入到sys.path

import sys
sys.path.insert(1,'/usr/local/lib/python3.5/site-packages/')

现在一切正常

0 个答案:

没有答案