Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Qt bindings not found error details #488

Open
dalthviz opened this issue May 22, 2024 · 2 comments
Open

Improve Qt bindings not found error details #488

dalthviz opened this issue May 22, 2024 · 2 comments

Comments

@dalthviz
Copy link
Member

dalthviz commented May 22, 2024

Adding more details on why no bindings are usable/found while also adding some general advise (like being sure not mix pip and conda versions of the same binding) could be worthy. Some related issues/discussions:

@dalthviz dalthviz added this to the v2.5.0 milestone May 22, 2024
@jni
Copy link

jni commented May 24, 2024

Thanks for making the issue @dalthviz! To save folks a click, here is the relevant part of the linked Zulip message, emphasis new:

The issue appears to be some incompatibility between pyqt from conda and PyQt5 from pip. Unfortunately, qtpy can bury the true cause of the error because of this try/except block. You can try to directly debug PyQt5 with this one-liner in the terminal:

python -c "from PyQt5.QtCore import PYQT_VERSION_STR"

if your issue is like mine, you'll get an error like this:

*** ImportError: dlopen(/Users/jni/micromamba/envs/all/lib/python3.11/site-packages/PyQt5/QtCore.abi3.so, 0x0002): Library not loaded: @rpath/QtCore.framework/Versions/5/QtCore
  Referenced from: <5DB832BD-87BC-3750-B686-5A0A711D09B3> /Users/jni/micromamba/envs/all/lib/python3.11/site-packages/PyQt5/QtCore.abi3.so
  Reason: tried: '/Users/jni/micromamba/envs/all/lib/python3.11/site-packages/PyQt5/Qt5/lib/QtCore.framework/Versions/5/QtCore' (no such file), '/Users/jni/micromamba/envs/all/lib/python3.11/site-packages/PyQt5/Qt5/lib/QtCore.framework/Versions/5/QtCore' (no such file), '/Users/jni/micromamba/envs/all/bin/../lib/QtCore.framework/Versions/5/QtCore' (no such file), '/Users/jni/micromamba/envs/all/bin/../lib/QtCore.framework/Versions/5/QtCore' (no such file)

I think it was caused by (a) installing pyqt from conda-forge, then (b) downgrading/upgrading PyQt5 with pip, perhaps through a dependency.

The main proposal is that the try/except block should "log" the pyqt5 error in some way and surface it, rather than silently trying another backend. Another option is to change the ImportError class in the except clause to a ModuleNotFoundError. Then not having PyQt5 will trigger looking for other backends, but having a broken PyQt5 will error.

@ccordoba12
Copy link
Member

Another option is to change the ImportError class in the except clause to a ModuleNotFoundError. Then not having PyQt5 will trigger looking for other backends, but having a broken PyQt5 will error.

I like this idea. I guess we're using ImportError in that block because there was no ModuleNotFoundError before Python 3.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants