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

QtBindingsNotFoundError on Importing Spyder with Python 3.11.6 #470

Closed
ryan-david-murphy opened this issue Nov 13, 2023 · 7 comments
Closed

Comments

@ryan-david-murphy
Copy link

ryan-david-murphy commented Nov 13, 2023

Description

I am encountering an issue with the qtpy module while trying to set up Spyder on Python 3.11.6. Despite having installed the necessary Qt and PyQt5 dependencies, qtpy is raising a QtBindingsNotFoundError when I try to import Spyder.

Steps to Reproduce

  1. Installed Qt and Qt5 via Homebrew.
  2. Installed pyqt5-sip and pyqt5 successfully.
  3. On attempting to import Spyder, qtpy raises an error.

Expected behavior: Spyder should import without any issues.

Actual behavior: Encountering a QtBindingsNotFoundError from qtpy.

Traceback

Traceback (most recent call last):
File "/Users/rdm4317/Development/firedrake/bin/qtpy", line 5, in
from qtpy.main import main
File "/Users/rdm4317/Development/firedrake/lib/python3.11/site-packages/qtpy/init.py", line 287, in
raise QtBindingsNotFoundError from None
qtpy.QtBindingsNotFoundError: No Qt bindings could be found

Versions

  • Python version: 3.11.6
  • Qt version: 5.15.10
  • PyQt5 version: 5.15.10
  • Operating System: macOS 13.6.1
  • Spyder version: 5.5.0

Additional Context

I have followed the standard installation procedure for Spyder and its dependencies. Any guidance on how to resolve this error would be greatly appreciated.

@ryan-david-murphy ryan-david-murphy changed the title QtBindingsNotFoundError on Importing Spyder with Python 3.9.2 QtBindingsNotFoundError on Importing Spyder with Python 3.11.6 Nov 13, 2023
@ccordoba12
Copy link
Member

Hey @rdm4317, thanks for reporting. I think this problem is caused because you're using a quite old Mac version (10.13), which is not compatible with the latest PyQt5 wheels.

The solution is for you to remove your virtualenv, create a new one and run there

pip install spyder pyqt==5.12 pyqtwebengine==5.12

If that also fails, please remove that virtualenv, create a new one and run

pip install spyder pyqt=5.10

Let us know if that works for you.

@ryan-david-murphy
Copy link
Author

Hey @ccordoba12, thanks for getting back to me so promptly. Apologies for the confusion above, I am running macOS Ventura 13.6.1, not 10.13. Consequently, I am unable to install the older versions suggested.

@ccordoba12
Copy link
Member

Sorry, my bad. Then this problem is perhaps caused because you're mixing several Pythons in your system.

A couple of questions about that:

  • How did you create the env placed in /Users/rdm4317/Development/firedrake?
  • Do you have Homebrew, MacPorts or another Python installed in your system?

@ryan-david-murphy
Copy link
Author

No problem!

My setup uses pyEnv, which you can find here: pyEnv Homebrew Formula, to manage different Python versions installed via Homebrew. The environment in question was created by running the Firedrake installation script (details here: Firedrake Installation), using Python 3.11.6 managed by pyEnv. This process successfully creates the virtual environment.

Previously, I had no trouble installing Spyder in this environment. However, I've run into a problem after updating Apple's Xcode from version 14.3.1 to 15.0. Since the Firedrake installation now requires the latest Xcode version, reverting to an older Xcode version isn't a feasible solution.

@dalthviz
Copy link
Member

Hi there, not totally sure but I think there are some issues related with PyQt5 wheels compatibility for arm64 macOS, is your macOS arm64 @rdm4317 ? Maybe you could get more info about the error by trying to import PyQt5 by itself. From some testing napari folks where doing on arm64 macOS machines I think you will get an ImportError regarding the C++ standard library).

@ryan-david-murphy
Copy link
Author

ryan-david-murphy commented Nov 13, 2023

Hey @dalthviz, thanks for getting back to me. Yes, it is an arm64 macOS.

import PyQt5 imports without error. However, from PyQt5.QtWidgets import QApplication, QLabel results in the following error:

 Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/rdm4317/Development/spyderEnv/lib/python3.11/site-packages/PyQt5/QtWidgets.abi3.so, 0x0002): Symbol not found: __ZTVNSt3__13pmr25monotonic_buffer_resourceE
  Referenced from: <8239A761-D3BE-396C-A445-F703655273B5> /Users/rdm4317/Development/spyderEnv/lib/python3.11/site-packages/PyQt5/Qt5/lib/QtWidgets.framework/Versions/5/QtWidgets
  Expected in:     <3EE92404-8FC3-374B-A598-D5C9A8CD64B5> /usr/lib/libc++.1.dylib

@ryan-david-murphy
Copy link
Author

Hey @dalthviz, @ccordoba12, I solved this issue by upgrading to macOS 14.1.1 as suggested by the above napari thread. Thanks for your help.

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