2

I recently downloaded PyQt5 from GitHub and put it in my python2.7 dist_packages, but when I do

>> import PyQt5

>> from PyQt5 import QtCore

I get

ImportError: cannot import name QtCore

I get this same error when I try to import any module from PyQt5.

Any help would be greatly appreciated.

Kile Maze
  • 73
  • 1
  • 11
  • Pyqt5, unlike some package where setup.py does nothing useful, isn't a package you can download from GitHub and copy-paste into your folder, there is a lot of setup and local configurations needed to take place. You'll need to run `python setup.py install`; or use `pip install pyqt5` directly. – Taku May 02 '18 at 00:01

1 Answers1

1

I recently downloaded PyQt5 from GitHub and put it in my python2.7 dist_packages

That's your problem. That's not the right way to install packages in Python. A small number of packages happen to work that way, but in general, you have to unpack what you downloaded, then go into the unpacked directory in your terminal/DOS prompt/etc., and run python setup.py install.

Or, much more simply, you can usually just do this:

pip install pyqt5

For more information see Installing PyQt5 in the PyQt5 docs and Installing Packages in the Python docs.

abarnert
  • 354,177
  • 51
  • 601
  • 671