Search code examples
pythoninstallationpippyqt5

Python 3 - ModuleNotFoundError: No module named 'PyQt5'


I have installed pyQt5 using pip install pyqt5.

However when I open my test code:

import sys    
from PyQt5 import QtWidgets, QtCore  

It is coming up with the error message:

Traceback (most recent call last):
  File "C:\Users\jessr\OneDrive\Documents\Coding Lessons\GUI.py", line 2, in <module>
    from PyQt5 import QtWidgets, QtCore
ModuleNotFoundError: No module named 'PyQt5'

I'm not sure how to fix it?

I tried different variations of the pip install (for example python -m pip install PyQt5 ) and checked my pip was updated.


Solution

  • Try to install PyQt5 in the virtual environment and use it. It always works for me.

    or

    If you are using Pycharm, install it from the Pycharm package.