PKU-MACDLab/IMPC-DR

ImportError: Failed to import any of the following Qt binding modules: PyQt5, PySide2

Closed this issue · 1 comments

Hi,

I encountered a PyQt related import error as the following:

Traceback (most recent call last):
  File "/home/randychen233/projects/ICON_lab/IMPC-DR/3D/app.py", line 20, in <module>
    from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
  File "/home/randychen233/anaconda3/envs/mosek/lib/python3.11/site-packages/matplotlib/backends/backend_qt5agg.py", line 7, in <module>
    from .backend_qtagg import (    # noqa: F401, E402 # pylint: disable=W0611
  File "/home/randychen233/anaconda3/envs/mosek/lib/python3.11/site-packages/matplotlib/backends/backend_qtagg.py", line 9, in <module>
    from .qt_compat import QT_API, QtCore, QtGui
  File "/home/randychen233/anaconda3/envs/mosek/lib/python3.11/site-packages/matplotlib/backends/qt_compat.py", line 133, in <module>
    raise ImportError(
ImportError: Failed to import any of the following Qt binding modules: PyQt5, PySide2

However, I have definitely installed both PyQt5 and PySide2, as shown in my conda environment below:

# packages in environment at /home/randychen233/anaconda3/envs/mosek:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main
_openmp_mutex             5.1                       1_gnu
blas                      1.0                         mkl
brotli                    1.0.9                h5eee18b_7
brotli-bin                1.0.9                h5eee18b_7
bzip2                     1.0.8                h7b6447c_0
ca-certificates           2023.08.22           h06a4308_0
clarabel                  0.6.0                    pypi_0    pypi
contourpy                 1.0.5           py311hdb19cb5_0
cvxpy                     1.4.1                    pypi_0    pypi
cycler                    0.11.0             pyhd3eb1b0_0
cyrus-sasl                2.1.28               h52b45da_1
dbus                      1.13.18              hb2f20db_0
ecos                      2.0.12                   pypi_0    pypi
expat                     2.5.0                h6a678d5_0
fontconfig                2.14.1               h4c34cd2_2
fonttools                 4.25.0             pyhd3eb1b0_0
freetype                  2.12.1               h4a9f257_0
giflib                    5.2.1                h5eee18b_3
glib                      2.69.1               he621ea3_2
gst-plugins-base          1.14.1               h6a678d5_1
gstreamer                 1.14.1               h5eee18b_1
icu                       58.2                 he6710b0_3
intel-openmp              2023.1.0         hdb19cb5_46305
jpeg                      9e                   h5eee18b_1
kiwisolver                1.4.4           py311h6a678d5_0
krb5                      1.20.1               h143b758_1
lcms2                     2.12                 h3be6417_0
ld_impl_linux-64          2.38                 h1181459_1
lerc                      3.0                  h295c915_0
libbrotlicommon           1.0.9                h5eee18b_7
libbrotlidec              1.0.9                h5eee18b_7
libbrotlienc              1.0.9                h5eee18b_7
libclang                  14.0.6          default_hc6dbbc7_1
libclang13                14.0.6          default_he11475f_1
libcups                   2.4.2                h2d74bed_1
libdeflate                1.17                 h5eee18b_1
libedit                   3.1.20221030         h5eee18b_0
libevent                  2.1.12               hdbd6064_1
libffi                    3.4.4                h6a678d5_0
libgcc-ng                 11.2.0               h1234567_1
libgomp                   11.2.0               h1234567_1
libllvm14                 14.0.6               hdb19cb5_3
libpng                    1.6.39               h5eee18b_0
libpq                     12.15                hdbd6064_1
libstdcxx-ng              11.2.0               h1234567_1
libtiff                   4.5.1                h6a678d5_0
libuuid                   1.41.5               h5eee18b_0
libwebp                   1.3.2                h11a3e52_0
libwebp-base              1.3.2                h5eee18b_0
libxcb                    1.15                 h7f8727e_0
libxkbcommon              1.0.1                h5eee18b_1
libxml2                   2.10.4               hcbfbd50_0
libxslt                   1.1.37               h2085143_0
lz4-c                     1.9.4                h6a678d5_0
matplotlib                3.8.0                    pypi_0    pypi
mkl                       2023.1.0         h213fc3f_46343
mkl-service               2.4.0           py311h5eee18b_1
mkl_fft                   1.3.8           py311h5eee18b_0
mkl_random                1.2.4           py311hdb19cb5_0
mosek                     10.1.15                 py311_0    mosek
munkres                   1.1.4                      py_0
mysql                     5.7.24               h721c034_2
ncurses                   6.4                  h6a678d5_0
nspr                      4.35                 h6a678d5_0
nss                       3.89.1               h6a678d5_0
numpy                     1.26.0          py311h08b1b3b_0
numpy-base                1.26.0          py311hf175353_0
opencv-python-headless    4.8.1.78                 pypi_0    pypi
openjpeg                  2.4.0                h3ad879b_0
openssl                   3.0.11               h7f8727e_2
osqp                      0.6.3                    pypi_0    pypi
packaging                 23.1            py311h06a4308_0
pcre                      8.45                 h295c915_0
pillow                    10.0.1          py311ha6cbd5a_0
pip                       23.3.1                   pypi_0    pypi
ply                       3.11            py311h06a4308_0
pybind11                  2.11.1                   pypi_0    pypi
pyparsing                 3.0.9           py311h06a4308_0
pyqt                      5.15.7          py311h6a678d5_0
pyqt5                     5.15.10                  pypi_0    pypi
pyqt5-qt5                 5.15.2                   pypi_0    pypi
pyqt5-sip                 12.13.0                  pypi_0    pypi
pyqt6-qt6                 6.5.3                    pypi_0    pypi
pyqt6-sip                 13.6.0                   pypi_0    pypi
pyside2                   5.13.2                   pypi_0    pypi
python                    3.11.5               h955ad1f_0
python-dateutil           2.8.2              pyhd3eb1b0_0
qdldl                     0.1.7.post0              pypi_0    pypi
qt-main                   5.15.2               h7358343_9
qt-webengine              5.15.9               h9ab4d14_7
qtwebkit                  5.212                h3fafdc1_5
readline                  8.2                  h5eee18b_0
scipy                     1.11.3                   pypi_0    pypi
scs                       3.2.3                    pypi_0    pypi
setuptools                68.0.0          py311h06a4308_0
shiboken2                 5.13.2                   pypi_0    pypi
sip                       6.6.2           py311h6a678d5_0
six                       1.16.0             pyhd3eb1b0_1
sqlite                    3.41.2               h5eee18b_0
tbb                       2021.8.0             hdb19cb5_0
tk                        8.6.12               h1ccaba5_0
toml                      0.10.2             pyhd3eb1b0_0
tornado                   6.3.3           py311h5eee18b_0
tzdata                    2023c                h04d1e81_0
wheel                     0.41.2          py311h06a4308_0
xz                        5.4.2                h5eee18b_0
zlib                      1.2.13               h5eee18b_0
zstd                      1.5.5                hc292b87_0

I am running Python 3 on Ubuntu 20.04 (Windows WSL 2). I have tried the following solutions (1, 2but neither has worked out. Any help is greatly appreciated!

@RandyChen233 Actually speaking, we only test our project in genrnal ubuntu 20.0.4 instead of WSL. The PyQt5 and PySide2 themself are highly related the OS and the detailed reason why WSL does not make sense is still unkown. Thus, I recommend you to run it on a general ubuntu.