Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install PyQt5 5.14.1 on Linux

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' >>>  
like image 438
ooo Avatar asked Jan 13 '20 06:01

ooo


People also ask

Does PyQt5 work on Linux?

The PyQt module can be used to create desktop applications with Python. In this article you'll learn how to install the PyQt module. Desktop applications made with PyQt are cross platform, they will work on Microsoft Windows, Apple Mac OS X and Linux computers (including Raspberry Pi).

Which Python version supports PyQt5?

PyQt5 wheels are specific to a particular version of Python. Only Python v3. 5 and later is supported. Wheels are provide for 32- and 64-bit Windows, 64-bit OS X and 64-bit Linux.

How do I run PyQt5 on Ubuntu?

Install PyQt5 via apt In Ubuntu you can install either from the command line or via "Software Center". The package you are looking for is named python3-pyqt5 . After install is finished, you should be able to run python (or python3 ) and import PyQt5 without errors.

What is PyQt5 qt5?

PyQt5 5.15. 7 PyQt5 is a comprehensive set of Python bindings for Qt v5. It is implemented as more than 35 extension modules and enables Python to be used as an alternative application development language to C++ on all supported platforms including iOS and Android.


2 Answers

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)
like image 131
alexforrence Avatar answered Oct 02 '22 13:10

alexforrence


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

like image 31
eyllanesc Avatar answered Oct 02 '22 14:10

eyllanesc