在 Linux 上安装 PyQt5 5.14.1 [英] Install PyQt5 5.14.1 on Linux
问题描述
pip3 安装 PyQt5收集 PyQt5使用缓存 https://files.pythonhosted.org/packages/3a/fb/eb51731f2dc7c22d8e1a63ba88fb702727b324c6352183a32f27f73b8116/PyQt5-5.14.1.tar.g命令 python setup.py egg_info 的完整输出:回溯(最近一次调用最后一次):文件<string>",第 1 行,在 <module> 中文件/usr/lib/python3.6/tokenize.py",第 452 行,打开缓冲区 = _builtin_open(文件名,'rb')FileNotFoundError: [Errno 2] 没有那个文件或目录:'/tmp/pip-build-b2zw891b/PyQt5/setup.py'----------------------------------------命令python setup.py egg_info"在/tmp/pip-build-b2zw891b/PyQt5/中失败,错误代码为 1
然后我从
我的最终目标是使用 pyqt5 运行烛台图.
sudo python3 -m pip install pyqt5 pyqtchart[sudo] oo 的密码:目录/home/oo/.cache/pip/http"或其父目录不属于当前用户所有,缓存已被禁用.请检查该目录的权限和所有者.如果使用 sudo 执行 pip,您可能需要 sudo 的 -H 标志.目录/home/oo/.cache/pip"或其父目录不属于当前用户所有,并且缓存轮已被禁用.检查该目录的权限和所有者.如果使用 sudo 执行 pip,您可能需要 sudo 的 -H 标志.已满足要求:/usr/lib/python3/dist-packages 中的 pyqt5已满足需求:/usr/local/lib/python3.6/dist-packages中的pyqtchart要求已经满足:PyQt5-sip<13,>=12.7 in/home/oo/.local/lib/python3.6/site-packages(来自pyqtchart)
但仍然出现相同的错误:
Python 3.6.9(默认,2019 年 11 月 7 日,10:44:02)[GCC 8.3.0] 在 Linux 上输入帮助"、版权"、信用"或许可证"以获取更多信息.>>>导入 PyQt5>>>导入 PyQt5.QtCore回溯(最近一次调用最后一次):文件<stdin>",第 1 行,在 <module> 中ModuleNotFoundError:没有名为PyQt5.sip"的模块>>>
我认为最初的 pip install
问题是由于 PyQt5 切换到最新版本的 manylinux2014 平台标签(请参阅车轮5.14.1 与 5.14.0).只有 pip 版本 >= 19.3 识别这个平台标签(ref),所以如果你碰巧有旧版本的 pip,它会尝试从源代码安装.
两个简单的选项(避免源安装):
- 通过
pip3 install --upgrade pip
将pip更新到最新版本 - 安装以前的版本,它使用了 manylinux1 (
pip3 install pyqt5==5.14.0
)
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::
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'
>>>
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
)
这篇关于在 Linux 上安装 PyQt5 5.14.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!