How to fix the error "QtWidgets.abi3.so Reason: image not found" in Python on Mac OS X Catalina?
Unsolved
Qt for Python
-
I am trying to run my python 3.9 code. I am on Mac OS X Catalina 10.15
I get an error when importing some PyQt5 modules:
from PyQt5 import QtWidgets, QtCore, QtGui From Pycharm, I get this error message: Traceback (most recent call last): File "/Volumes/GoogleDrive/My Drive/project/main.py", line 135, in <module> from PyQt5 import QtWidgets, QtCore, QtGui ImportError: dlopen(/usr/local/lib/python3.9/site-packages/PyQt5/QtWidgets.abi3.so, 2): Library not loaded: @rpath/QtWidgets.framework/Versions/5/QtWidgets Referenced from: /usr/local/lib/python3.9/site-packages/PyQt5/QtWidgets.abi3.so Reason: image not found
from terminal, I get this error:
dyld: loaded: <9D893D18-53D8-3C59-80F1-3E37DF41D246> /usr/local/lib/python3.9/site-packages/PyQt5/QtWidgets.abi3.so dyld: unloaded: <9D893D18-53D8-3C59-80F1-3E37DF41D246> /usr/local/lib/python3.9/site-packages/PyQt5/QtWidgets.abi3.so Traceback (most recent call last): File "/Volumes/GoogleDrive/My Drive/project/main.py", line 135, in <module> from PyQt5 import QtWidgets, QtCore, QtGui ImportError: dlopen(/usr/local/lib/python3.9/site-packages/PyQt5/QtWidgets.abi3.so, 2): Library not loaded: @rpath/QtWidgets.framework/Versions/5/QtWidgets Referenced from: /usr/local/lib/python3.9/site-packages/PyQt5/QtWidgets.abi3.so Reason: image not found
I tried to upgrade pyqt5 with the command:
python3 -m pip install PyQt5 upgrade
but I get this error message:
Requirement already satisfied: PyQt5 in /usr/local/lib/python3.9/site-packages (5.15.4) dyld: loaded: <F1258E44-15BC-3DBB-8563-B8703B358AD9> /usr/lib/libusrtcp.dylib ERROR: Could not find a version that satisfies the requirement upgrade (from versions: none) ERROR: No matching distribution found for upgrade
I. checked with :
python3 -m pip freeze
Here are all the PyQt5 modules I have:
PyQt3D==5.15.5 PyQt5==5.15.4 PyQt5-Qt5==5.15.2 PyQt5-sip==12.9.0 PyQt5-stubs==5.15.2.0 PyQt6==6.2.0 PyQt6-3D==6.2.0 PyQt6-Charts==6.2.0 PyQt6-DataVisualization==6.2.0 PyQt6-NetworkAuth==6.2.0 PyQt6-sip==13.1.0 PyQtChart==5.15.5 PyQtDataVisualization==5.15.5 PyQtNetworkAuth==5.15.5 PyQtPurchasing==5.15.5 PyQtWebEngine==5.15.5 PyQtWebEngine-Qt5==5.15.2
So I try with Homebrew :
brew install pyqt5
and I get this output:
Warning: pyqt@5 5.15.6 is already installed and up-to-date. To reinstall 5.15.6, run: brew reinstall pyqt@5
I search help on forum and I read some solution in my .zshrc file:
DYLD_LIBRARY_PATH="/Library/Java/JavaVirtualMachines/jdk-15.0.2.jdk/Contents/Home:/usr/local/lib/python3.9/site-packages:/usr/local/lib/python3.9/site-packages/PySide2" PATH="/usr/local/bin:/Library/Java/JavaVirtualMachines/jdk-15.0.2.jdk/Contents/Home:/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home:/Users/alisa/.wdm/drivers/geckodriver/macos/v0.30.0:/Users/alisa/Android/cmdline-tools/latest/bin:/Users/alisa/Android/platform-tools:/bin:/opt/local/bin:/sbin:/usr/bin:/usr/local/Cellar/python@3.9/:/usr/local/Cellar/python@3.9/3.9.12_1/Frameworks/Python.framework/Versions/3.9/bin/:/usr/local/Cellar/python@3.9/3.9.12_1/bin/:/usr/local/lib/python3.9/site-packages:/usr/local/opt/qt@/bin/:/usr/local/opt/qt@6/bin/:/usr/sbin/"
My file seems fine or did I forgot something?
Can anyone help me please to fix this issue?
-
Hi,
Remove the DYLD_LIBRARY_PATH, you are putting there PySide2 while using PyQt5.
Also, don't mix brew and pip installation.
What I would recommend is to create a clean virtual environment install PyQt there and retest your script.