14

When I try to import the following using PyCharm:

import sys

from PyQt5.QtWidgets import QtGui, QtCore

it generates this error when compiling:

ImportError: No module named 'PyQt5'

I want PyQt5 in Pycharm. Can you explain in complete detail what should I do to install it?

khelwood
  • 55,782
  • 14
  • 81
  • 108
Noblood
  • 159
  • 1
  • 1
  • 6
  • 1
    What OS is this on? I had this problem on OSX Mavericks and found a solution here: http://stackoverflow.com/a/20192708/591525 – jsmaupin Dec 05 '13 at 19:18

6 Answers6

12

Try

PyCharm -> file -> settings -> project:'your_project' - project interpreter -> + -> install PyQt5

pip install PyQt5 doesn't work for PyCharm

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Misha Solovyev
  • 149
  • 1
  • 5
5

Install PyQt5 from the installer on the PyQt website. It probably just installs PyQt as a site package to the python version you point to in your 'Path', although it may ask for your preference - cant remember.

It also installs other useful PyQt stuff to your hard drive.

It also updates the path to the PyQt module so you can easily run the pyuic5.bat file from the command line to convert the .ui generated by 'Qt Designer' to a python file.

No configuration of PyCharm should be necessary and it will pick up any new site packages added automatically.

also...

from PyQt5 import QtCore, QtGui, QtWidgets
Ninga
  • 689
  • 7
  • 14
2

The reason why you cannot pip install PyQt5 is because the Python Package Index (PyPi -- where pip searches for packages) was not provided with the files to serve.

Put another way: when you use pip search, you are being provided with a list of projects that have been registered with PyPi, whether or not downloadable source files were made available.

Contrast the PyPi page for easyos, where a download of the files has been made available, to PyQt5, where they have not been.

To install PyQt5, follow the "Download URL" on the PyPi page and install it according to the provider's instructions. You may have to repeat this process for additional packages and should make note of steps taken in case you have to repeat them in the future -- steps taken outside of pip do not make it into your requirements.txt.

1

Note PyQt5 pip packaging requires Python 3.5 or later. With PyCharm 2017 you can install from the ide write the ´import PyQt5´ in your code, press alt enter on the missing import and select "import PyQt5".

Or from the command line as per the latest installation instructions:

pip3 install pyqt5

Tatu Lahtela
  • 4,514
  • 30
  • 29
0

For Linux OS users(Ubuntu and Debian base distributions):

For installing PyQt4:

sudo apt install pyqt4-dev-tools

For installing PyQt5:

sudo apt install pyqt5-dev-tools

In General, GNU/Linux users can install pyqt5 it using the below command:

pip3 install pyqt5

The installation instructions are fully described here.

Wall-E
  • 43
  • 7
-1

Open terminal from PyCharm (View -> Tools Windows -> Terminal) and type the following:

python -m pip install pyqt5