Home > Software design >  PyQt5 not found
PyQt5 not found

Time:08-20

I get the following error

ImportError: cannot import name 'QtCore' from 'PyQt5' (/usr/lib/python3/dist-packages/PyQt5/init.py)

which makes me think that the module is not installed.

When I try to install it I get:

pip3 install PyQt5

Defaulting to user installation because normal site-packages is not writeable

Requirement already satisfied: PyQt5 in /usr/lib/python3/dist-packages (5.14.1)

I also tried the following and got

sudo pip3 install PyQt5

Requirement already satisfied: PyQt5 in /usr/lib/python3/dist-packages (5.14.1)

WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

WARNING: There was an error checking the latest version of pip.

Any idea? I am running python3.10 on Ubuntu

CodePudding user response:

did you try to launch your program with python3 program.py or python program.py depending on the one you already use ?

Also try to run a pip3 list to see if the module is installed.

You can try to install with python3 -m pip install PyQT5 or just python -m pip install PyQT5

CodePudding user response:

you can try reinstalling

$ python3 -m pip install --upgrade --force-reinstall PyQt5

however I recommend using a virtual environment (e.g. using venv module) to install the modules and use them:

$ sudo apt install python3-venv
$ python3 -m venv my-project-env
$ source my-project-env/bin/activate

then install required modules in your project's virtual environment

CodePudding user response:

It seems that you need to install/upgrade matplotlib.

source: ImportError: cannot import name 'QtCore'

  • Related