On Ubuntu 22.04 (5.15.0-43-generic) I freshly updated spyder using pip
as follow:
$ sudo -H pip3 install --upgrade spyder
everything went fine, but it throws this error when I start spyder now:
$ spyder
Traceback (most recent call last):
File "/usr/local/bin/spyder", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.10/dist-packages/spyder/app/start.py", line 248, in main
from spyder.app import mainwindow
File "/usr/local/lib/python3.10/dist-packages/spyder/app/mainwindow.py", line 57, in <module>
from qtpy import QtWebEngineWidgets # analysis:ignore
File "/usr/local/lib/python3.10/dist-packages/qtpy/QtWebEngineWidgets.py", line 29, in <module>
from PyQt5.QtWebEngineWidgets import QWebEnginePage
ImportError: /usr/local/lib/python3.10/dist-packages/PyQt5/Qt5/lib/libQt5Network.so.5: undefined symbol: _ZdaPvm, version Qt_5
Some more info:
$ python3 --version
Python 3.10.4
$ pip list | grep -i pyqt
PyQt5 5.15.6
PyQt5-Qt5 5.15.2
PyQt5-sip 12.11.0
PyQtWebEngine 5.15.5
PyQtWebEngine-Qt5 5.15.2
$ pip list | grep -i spyder
pyls-spyder 0.4.0
spyder 5.3.2
spyder-kernels 2.3.2
And I'm not able to uninstall PyQt5:
$ sudo -H pip uninstall pyqt5
Found existing installation: PyQt5 5.15.6
ERROR: Cannot uninstall PyQt5 5.15.6, RECORD file not found. Hint: The package was installed by sip-build.
The last line being printed in red in the terminal.
From that point, I'm not able to find relevant information on how to debug this in order to make spyder work again.
What could I do to fix this error?
Okay, this fixed it for me:
$ sudo -H pip3 install --force-reinstall spyder
it will probably throw some errors such as:
Attempting uninstall: PyQtWebEngine
Found existing installation: PyQtWebEngine 5.15.5
ERROR: Cannot uninstall PyQtWebEngine 5.15.5, RECORD file not found. Hint: The package was installed by sip-build.
which, if you try to update it individually will show:
$ sudo -H pip3 install -U PyQtWebEngine
Requirement already satisfied: PyQtWebEngine in /usr/lib/python3/dist-packages (5.15.5)
Collecting PyQtWebEngine
Using cached PyQtWebEngine-5.15.6-cp37-abi3-manylinux1_x86_64.whl (230 kB)
Requirement already satisfied: PyQt5>=5.15.4 in /usr/local/lib/python3.10/dist-packages (from PyQtWebEngine) (5.15.7)
Requirement already satisfied: PyQtWebEngine-Qt5>=5.15.0 in /usr/local/lib/python3.10/dist-packages (from PyQtWebEngine) (5.15.2)
Requirement already satisfied: PyQt5-sip<13,>=12.11 in /usr/local/lib/python3.10/dist-packages (from PyQtWebEngine) (12.11.0)
Requirement already satisfied: PyQt5-Qt5>=5.15.0 in /usr/local/lib/python3.10/dist-packages (from PyQt5>=5.15.4->PyQtWebEngine) (5.15.2)
Installing collected packages: PyQtWebEngine
Attempting uninstall: PyQtWebEngine
Found existing installation: PyQtWebEngine 5.15.5
ERROR: Cannot uninstall PyQtWebEngine 5.15.5, RECORD file not found. Hint: The package was installed by sip-build.
Therefore, in that case, run the installation using the --ignore-installed
flag on the incriminated package, which should install it without any trouble:
$ sudo -H pip3 install --ignore-installed PyQtWebEngine
Collecting PyQtWebEngine
Using cached PyQtWebEngine-5.15.6-cp37-abi3-manylinux1_x86_64.whl (230 kB)
Collecting PyQtWebEngine-Qt5>=5.15.0
Using cached PyQtWebEngine_Qt5-5.15.2-py3-none-manylinux2014_x86_64.whl (67.5 MB)
Collecting PyQt5>=5.15.4
Using cached PyQt5-5.15.7-cp37-abi3-manylinux1_x86_64.whl (8.4 MB)
Collecting PyQt5-sip<13,>=12.11
Using cached PyQt5_sip-12.11.0-cp310-cp310-manylinux1_x86_64.whl (359 kB)
Collecting PyQt5-Qt5>=5.15.0
Using cached PyQt5_Qt5-5.15.2-py3-none-manylinux2014_x86_64.whl (59.9 MB)
Installing collected packages: PyQtWebEngine-Qt5, PyQt5-Qt5, PyQt5-sip, PyQt5, PyQtWebEngine
Successfully installed PyQt5-5.15.7 PyQt5-Qt5-5.15.2 PyQt5-sip-12.11.0 PyQtWebEngine-5.15.6 PyQtWebEngine-Qt5-5.15.2
After what the above-mentioned error will never show up again. Here as an example:
$ sudo -H pip3 install -U PyQtWebEngine
Requirement already satisfied: PyQtWebEngine in /usr/local/lib/python3.10/dist-packages (5.15.6)
Requirement already satisfied: PyQtWebEngine-Qt5>=5.15.0 in /usr/local/lib/python3.10/dist-packages (from PyQtWebEngine) (5.15.2)
Requirement already satisfied: PyQt5-sip<13,>=12.11 in /usr/local/lib/python3.10/dist-packages (from PyQtWebEngine) (12.11.0)
Requirement already satisfied: PyQt5>=5.15.4 in /usr/local/lib/python3.10/dist-packages (from PyQtWebEngine) (5.15.7)
Requirement already satisfied: PyQt5-Qt5>=5.15.0 in /usr/local/lib/python3.10/dist-packages (from PyQt5>=5.15.4->PyQtWebEngine) (5.15.2)
Repeat the same procedure for all offending packages.
Finally update spyder:
$ sudo -H pip3 install --force-reinstall spyder
And voila. A working spyder should be available.
As an aside: please note the -H
option after sudo
. This install packages under /usr/local/lib/python3.xx/dist-packages
which will normally not conflict with apt
system wide installed packages (which are under /usr/lib/python3/dist-packages
) and which you definitely don't want to touch another what than with apt
actually!
I'm using this to avoid installing the same packages on a user-basis by invoking pip
without sudo
, which will install them under ~/.local/lib/python3.10/site-packages/
for every user on the machine.