gpt4 book ai didi

python - 在 Linux 上安装 PyQt5 5.14.1

转载 作者:行者123 更新时间:2023-12-03 14:54:35 28 4
gpt4 key购买 nike

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/download5 下载了 zip 文件夹并运行:
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

成功的

但仍然出现同样的错误 No module named 'PyQt5.sip'import PyQt5.QtCore
也试过 PyQtChart 但还是报错
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/download 下载了 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截图::
enter image description here

我的最终目标是使用 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)

但仍然出现相同的错误:
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'
>>>

最佳答案

我认为初始pip install问题是由于 PyQt5 切换到最新版本的 manylinux2014 平台标签(请参阅 PyPI 上的轮子 5.14.1 vs 5.14.0)。只有 pip 版本 >= 19.3 识别这个平台标签( ref ),所以如果你碰巧有一个旧版本的 pip,它会尝试从源代码安装。

两个简单的选项(避免源安装):

  • 通过 pip3 install --upgrade pip 将 pip 更新到最新版本
  • 安装以前的版本,它使用了 manylinux1 ( pip3 install pyqt5==5.14.0 )
  • 关于python - 在 Linux 上安装 PyQt5 5.14.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59768179/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com