在Linux上安装PyQt5 5.14.1 [英] Install PyQt5 5.14.1 on Linux

查看:2394
本文介绍了在Linux上安装PyQt5 5.14.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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/

然后我从 https://www.riverbankcomputing.com/software/pyqt/下载了zip文件夹download5 并运行:

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

成功

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

所以我安装了

pip3 install PyQt5.sip
pip3 install sip

成功

,但对于import PyQt5.QtCore

还尝试了PyQtChart,但仍然出错

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/

我还从 https://www.riverbankcomputing.com/software/pyqtchart/下载了zip文件夹下载并运行:

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屏幕截图::

QT screenshot::

我的最终目标是使用pyqt5运行烛台图.

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'
>>> 

推荐答案

PyQt5到pypi的最新版本似乎存在错误,因此我安装了5.14版本:

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

在main.py中复制我先前的答案的示例,然后运行:

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.

为进行测试,我使用了以下 Dockerfile

这篇关于在Linux上安装PyQt5 5.14.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆