简体   繁体   中英

PyQt5: ModuleNotFoundError: No module named 'PyQt5'

I have installed Python 3.7.1 and trying to run a form created using QTdesigner.But this error occurred.I have also installed PyQt5 module using

pip install PyQt5 

The error is:

from PyQt5 import QtCore, QtGui, QtWidgets   

ModuleNotFoundError: No module named 'PyQt5'

Python and pip seem to be running on different versions.

If you're using various versions of Python, use python -m pip install PyQt5 instead of pip .

Try this : Check your python directory correctly installed or Not. Go to the below a directory by cmd and run the commands.

C:\Users\PC_NAME\AppData\Local\Programs\Python\Python37-32\Scripts>

pip install PyQt5

your PRO.py program now ready to run successfully.

It seems like your pycharm is configured to use virtual environment. Try installing PyQt5 from pycharm terminal. It will install PyQt5 in your virtual environment and it fixed the issue in my case.

您可以使用 pip3 安装一个 python3 模块:

pip3 install PyQt5

I have used all the below mentioned commands having done it with both VS terminal and cmd:

python -m pip install pyqt5
pip3 install pyqt5
python -m pip.py install pyqt5

Although it did install correctly but when I import PyQt5.QWidgets i get an error stating module not found. I am saying it did install correctly because when I run these commands again get a message "Requirements already satisfied".

I had a similar error when starting with PyQT5. Do not know if this might answer your question but here was my scenario. I had both python 2.7 and python 3.7 on my machine. My pip 2.7 was added to the path instead of the 3.7. So i removed python 2.7 from the path, reinstalled python 3.7 and added to the path and restarted. After that used pip to install pyqt5 and it worked like a charm

我通过在 Windows 上使用python -m pip install PyQt5而不是pip install PyQt5解决了它

For me the problem was solved by uninstalling the pip version and instead installing from apt:

pip3 uninstall PyQt5
sudo apt-get install python3-pyqt5

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM