简体   繁体   中英

PyQt5 not working on macOs sierra

I have been trying to use the pyqt5 library for close to over an 5 hours now, it keeps on saying:-

from PyQt5.QtGui import *

ImportError: dlopen(/usr/local/lib/python3.6/site-packages/PyQt5/QtGui.so, 2): Library not loaded: @rpath/QtGui.framework/Versions/5/QtGui
Referenced from: /usr/local/lib/python3.6/site-packages/PyQt5/QtGui.so Reason: image not found

Finally got it working , after 1 million fruitless tries.

  1. Get homebrew then brew install pyqt.
  2. LDFLAGS=-L/usr/local/opt/qt/lib CPPFLAGS=-I/usr/local/opt/qt/include pip3 install PyQt5 all on 1 line.

Then viola !

I also encountered this problem with pyqt installed via conda, when importing the following:

from PyQt5 import QtGui, QtCore

Updating the package solved the problem for me.

pyqt: 5.6.0-py36_1 conda-forge --> 5.6.0-py36h8210e8a_6 conda-forge

Note that there's also a new version available (pyqt 5.9.2), but this update resolved my issue.

I solved this problem by going to Python 3.6. on OSX

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM