ginga
ginga copied to clipboard
Incompatibility with PyQt5 5.15.4 that is pip installed into conda env
I got a following report offline. I'll update if I get more info. Probably happened on Mac OSX.
I'm using the Ginga Python tools and it just gave me an error in my new environment. Could it be that Ginga only works with a previous version of PyQt5? I have 5.15.4 now.
Downgrading to 5.10.1 solved the issue.
Thats the traceback I got. I googled the error and this StackOverflow thread suggested to downgrade PyQt5 (even tho this was for Spyder). So I gave it a try and with the 5.10.1 version it was working again. Not sure if that was the version I needed to downgrade to but I didn't try the others.
objc[14801]: Class RunLoopModeTracker is implemented in both /Users/nluetzgendorf/anaconda3/envs/comm/lib/python3.7/site-packages/PyQt5/Qt5/lib/QtCore.framework/Versions/5/QtCore (0x1185f1288) and /Users/nluetzgendorf/anaconda3/envs/comm/lib/libQt5Core.5.9.7.dylib (0x122754a80). One of the two will be used. Which one is undefined.
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
~/Library/JWST/nirspec/nrspymod/nrspymod/run/p_spec_man_slit_im_fpa.py in <module>
57 import json
58 import numpy as np
---> 59 from nrspymod.utils.ginga_tools import run_shapes
60
61 from nrspymod.model.model_parameters import _slit_list
~/Library/JWST/nirspec/nrspymod/nrspymod/utils/ginga_tools.py in <module>
29 import matplotlib
30 matplotlib.use('TkAgg')
---> 31 from ginga.qtw.QtHelp import QtGui, QtCore
32 from qtpy.QtGui import QFont
33 from ginga import AstroImage, colors
~/anaconda3/envs/comm/lib/python3.7/site-packages/ginga/qtw/QtHelp.py in <module>
50 from qtpy.QtWidgets import QApplication # noqa
51 try:
---> 52 from qtpy.QtWebEngineWidgets import QWebEngineView as QWebView # noqa
53 except ImportError as e:
54 pass
~/anaconda3/envs/comm/lib/python3.7/site-packages/qtpy/QtWebEngineWidgets.py in <module>
20 if PYQT5:
21 try:
---> 22 from PyQt5.QtWebEngineWidgets import QWebEnginePage
23 from PyQt5.QtWebEngineWidgets import QWebEngineView
24 from PyQt5.QtWebEngineWidgets import QWebEngineSettings
ValueError: PyCapsule_GetPointer called with incorrect name
Oh and yes its macOS Catalina 10.15.7
How exactly was your "new environment" created? The SO thread mentioned problem caused by people mixing up pip
and conda
installs of Qt components.
On my conda
env, I only get 5.9.x and not even an option to upgrade beyond that.
$ conda list PyQt
# packages in environment at .../miniconda/envs/py38:
#
# Name Version Build Channel
pyqt 5.9.2 py38h05f1152_4
https://anaconda.org/anaconda/pyqt
Thanks for the extra info and traceback; really helpful!
Oh yes that might be the issue. Its installed via pip. I do this because it is one of the dependecies in my package (which is not in conda) so the only way (I know) how to have them installed when I do the installation of the package is via pip.
it is one of the dependecies in my package (which is not in conda)
That is tricky but distribution of downstream package is out of scope.
Let's leave this open for a bit, but I am not sure if there is anything we can fix here in Ginga. Still, it is good to have this issue created in case others run into the same problem, so thanks again for reporting it!
Yes I will just solve it in my package making sure it installs the lower version for now.
Yes, looks like the only thing we could do is to change the try/except ImportError to a try/except Exception in QtHelp
(looking at the stack dump). My guess is that since this error affects multiple packages using qtpy
, the fix will probably happen there.
Agree we should hold off for a bit and see if qtpy
fixes that. (We should search and see if the error has been reported there yet. Will do that now...)
Hmm, general web search for this error seems to indicate that the problem stretches back a couple of years at least, and occurs when various versions of Qt are mixed, e.g. when conda and pip install different versions of qt-linked code, or when the PYTHONPATH exposes this.
I heard that "Apple silicon" macs only have the choice of PyQt6. I only have one or two first-hand reports from colleagues, so this is not definitive. In any case, we've since merged support for PyQt6, so perhaps that is the workaround for this issue. qtpy
added support for PyQt6/PySide6 in v2.0.1, FWIW.
Ginga working fine with PyQt 5.15.10 and also PyQt6. There is a known bug in the latest Qt6 and PySide6 (6.6.1). Downgrading either of them to lower version than 6.6.1 appears to work.
Have tested on Linux and Mac OS X.