36
pip3 install PyQt5
Collecting PyQt5
  Using cached https://files.pythonhosted.org/packages/3a/fb/eb51731f2dc7c22d8e1a63ba88fb702727b324c6352183a32f27f73b8116/PyQt5-5.14.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3.6/tokenize.py", line 452, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-build-b2zw891b/PyQt5/setup.py'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-b2zw891b/PyQt5/

Then I downloaded zip folder from https://www.riverbankcomputing.com/software/pyqt/download5 and run:

python3 configure.py --qmake /home/oo/Qt/5.14.0/gcc_64/bin/qmake
make
sudo make install

Successful

>>> import PyQt5
>>> import PyQt5.QtCore
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5.sip'
>>> 

So I installed

pip3 install PyQt5.sip
pip3 install sip

Successful

but still getting same error No module named 'PyQt5.sip' for import PyQt5.QtCore

also tried PyQtChart but still error

pip3 install PyQtChart
Collecting PyQtChart
  Using cached https://files.pythonhosted.org/packages/83/35/4f6328db9a31e2776cdcd82ef7688994c11e265649f503858f1913444ba9/PyQtChart-5.14.0-5.14.0-cp35.cp36.cp37.cp38-abi3-manylinux1_x86_64.whl
Collecting PyQt5>=5.14 (from PyQtChart)
  Using cached https://files.pythonhosted.org/packages/3a/fb/eb51731f2dc7c22d8e1a63ba88fb702727b324c6352183a32f27f73b8116/PyQt5-5.14.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3.6/tokenize.py", line 452, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-build-gzep4mr7/PyQt5/setup.py'

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-gzep4mr7/PyQt5/

I also downloaded zip folder from https://www.riverbankcomputing.com/software/pyqtchart/download and run:

python3 configure.py --qmake /home/oo/Qt/5.14.0/gcc_64/bin/qmake
Error: Unable to import PyQt5.QtCore. Make sure PyQt5 is installed.

QT screenshot:: enter image description here

My end goal is to run candlestick chart using pyqt5.

sudo python3 -m pip install pyqt5 pyqtchart
[sudo] password for oo:  
The directory '/home/oo/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/oo/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: pyqt5 in /usr/lib/python3/dist-packages
Requirement already satisfied: pyqtchart in /usr/local/lib/python3.6/dist-packages
Requirement already satisfied: PyQt5-sip<13,>=12.7 in /home/oo/.local/lib/python3.6/site-packages (from pyqtchart)

but still getting same error:

Python 3.6.9 (default, Nov  7 2019, 10:44:02) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt5
>>> import PyQt5.QtCore
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5.sip'
>>> 
3
  • elementary OS 5.1 Hera
    – ooo
    Jan 13, 2020 at 6:21
  • Update the question, I am still getting same error
    – ooo
    Jan 13, 2020 at 6:49
  • I also removed all PYQT packages from /usr/local/lib/python3.6/dist-packages/ and then installed pyqt5 pyqtchart pyqt5.sip sip but still for import PyQt5.QtCore error is ModuleNotFoundError: No module named 'PyQt5.sip'
    – ooo
    Jan 13, 2020 at 7:23

8 Answers 8

70

I think the initial pip install woes were due to PyQt5 switching to the manylinux2014 platform tag for the latest release (see the wheels on PyPI for 5.14.1 vs 5.14.0). Only pip versions >= 19.3 recognize this platform tag (ref), so if you happen to have an older version of pip, it would instead try to install from source.

Two easy options (to avoid the source install):

  • Update pip to the latest via pip3 install --upgrade pip
  • Install the previous release, which used manylinux1 (pip3 install pyqt5==5.14.0)
4
  • Installing 5.14.0 fixed it for me
    – Steven
    Jan 12, 2021 at 20:38
  • pip3 upgrade to 21.0.1 worked on WSL running Pengwin Enterprise Scientific Linux.
    – skytaker
    Apr 8, 2021 at 16:22
  • Yeah, upgrading stuff fixes 90 percent of the problems !
    – TheEagle
    Apr 13, 2021 at 9:37
  • Upgrading pip worked, but then I missed libxcb-util.so.1 (Could not load the Qt platform plugin "xcb" in "" even though it was found.) Installing the previous release (5.14.0) let me run the app. Thanks.
    – Ale
    Apr 15, 2021 at 15:02
20

It seems that there is a bug in the latest version of PyQt5 to pypi so I installed a version 5.14:

sudo apt-get update && \
    sudo apt-get autoclean

sudo apt-get update && sudo apt-get install \
    -y --no-install-recommends \
    python3-pip \
    python3-setuptools

sudo python3 -m pip install pyqt5==5.14 pyqtchart==5.14

Copy the example of my previous answer in the main.py and then run:

python3 main.py

I recommend you search the folders and files generated by your failed attempts and delete them.

For my test I used the following Dockerfile

1
  • Why did you use sudo to run pytho3 -m pip?
    – WesR
    Feb 27, 2020 at 2:50
10

I also had the same issue installing PyQt5 (while trying to install ReText).

On Ubuntu 18.04 with Python 3.6.9 and Pip 9.0.1, I was able to pip install PyQt5 with these steps:

python3 -m venv env
source env/bin/activate
pip3 install pyqt5 --only-binary pyqt5

That was enough to make pip download the PyQt5-5.14.0-5.14.0-cp35.cp36.cp37.cp38-abi3-manylinux1_x86_64.whl binary wheel (that doesn't need/use the setup.py) instead of building from the source tarball.

According to https://pypi.org/project/PyQt5/#files, there are other binary wheels too, so hopefully that'll cover most platform needs.

2

Sometimes it is very difficult to install PyQt5 on Debian or Ubuntu Linux distro. I was able to install it for python3 on my system running Debian 10 buster (stable).
I installed it with the apt package manager.

sudo apt-get update 
sudo apt-get install python3-pyqt5
1
  • The only option that worked for me, all pip installs of the 5.14.x and 5.15 versions failed because of syntax errors in the requirements or obscure files missing.
    – Michael H
    Sep 5, 2020 at 10:12
1

I have this problem too. It's because your pip is on older version and you should update it by using the below commands:

pip3 install setuptools wheel
pip3 install --upgrade pip
pip3 install --user pyqt5
0

For those who do not desperatly need 5.14, 5.12 can be a solution. This worked for me:

sudo python3 -m pip install pyqt5==5.12 pyqtchart==5.12
0

As the Question showed, you are downloading tar.zip file not wheel. Installing QT with pip is only allowed with wheel. Choose the version that has wheel file in PyPI homepage and matches to your Python version.

0

I had to build right version of sip from source in order to build desired version of PyQt5 from source and then I also got following error:

No module named 'PyQt5.sip'

and then

python3 -m pip install PyQt5.sip

solved the issue

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.