首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在Linux上安装PyQt5 5.14.1

在Linux上安装PyQt5 5.14.1
EN

Stack Overflow用户
提问于 2020-01-13 06:06:55
回答 7查看 43.7K关注 0票数 35
代码语言:javascript
运行
复制
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文件夹并运行:

代码语言:javascript
运行
复制
python3 configure.py --qmake /home/oo/Qt/5.14.0/gcc_64/bin/qmake
make
sudo make install

成功

代码语言:javascript
运行
复制
>>> import PyQt5
>>> import PyQt5.QtCore
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5.sip'
>>> 

所以我安装了

代码语言:javascript
运行
复制
pip3 install PyQt5.sip
pip3 install sip

成功

但仍然获得相同的错误No module named 'PyQt5.sip'用于import PyQt5.QtCore

也尝试过PyQtChart,但仍然出错

代码语言:javascript
运行
复制
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文件夹并运行:

代码语言:javascript
运行
复制
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截图::

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

代码语言:javascript
运行
复制
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)

但仍然会出现同样的错误:

代码语言:javascript
运行
复制
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'
>>> 
EN

回答 7

Stack Overflow用户

回答已采纳

发布于 2020-01-18 04:14:18

我认为最初的pip install问题是由于PyQt5在最新版本中切换到manylinux2014平台标签(参见PyPI上的5.14.1 vs 5.14.0)。只有pip版本的>= 19.3识别这个平台标记(参考),所以如果您碰巧有一个旧版本的pip,那么它将尝试从源代码安装。

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

  • 通过pip3 install --upgrade pip将pip更新为最新的
  • 安装上一个版本,它使用了manylinux1 (pip3 install pyqt5==5.14.0)
票数 70
EN

Stack Overflow用户

发布于 2020-04-07 14:37:35

我在安装PyQt5 (同时试图安装ReText)时也遇到了同样的问题。

Ubuntu 18.04Python 3.6.9Pip 9.0.1上,我能够通过以下步骤安装PyQt5

代码语言:javascript
运行
复制
python3 -m venv env
source env/bin/activate
pip3 install pyqt5 --only-binary pyqt5

这足以让pip下载PyQt5-5.14.0-5.14.0-cp35.cp36.cp37.cp38-abi3-manylinux1_x86_64.whl二进制轮(不需要/使用setup.py),而不是从源tarball构建。

根据https://pypi.org/project/PyQt5/#files的说法,还有其他的二进制引擎,所以希望它能满足大多数平台的需求。

票数 10
EN

Stack Overflow用户

发布于 2020-07-08 09:14:59

有时候,在Debian或Ubuntu发行版上安装PyQt5非常困难。我能够在运行Debian10buster(稳定)的系统上为python3安装它。

我用apt软件包管理器安装了它。

代码语言:javascript
运行
复制
sudo apt-get update 
sudo apt-get install python3-pyqt5
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59711301

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档