如何安装PyQt并解决IOError问题

31
我正尝试使用pip安装PyQt包,但是出现了这个错误:
~$ pip install PyQt

Downloading/unpacking PyQt  
Downloading PyQt-x11-gpl-4.8.3.tar.gz
(9.8Mb): 9.8Mb downloaded   Running
setup.py egg_info for package PyQt
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
    IOError: [Errno 2] No such file or directory:
'/home/john/build/PyQt/setup.py'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 14, in
<module>

IOError: [Errno 2] No such file or
directory:
'/home/john/build/PyQt/setup.py

---------------------------------------- Command python setup.py egg_info
failed with error code 1 Storing
complete log in
/home/john/.pip/pip.log

1
有人在这里添加了一个问题:https://github.com/pypa/pip/issues/579 - E.Z.
6个回答

15

这是因为该文件有一个configure.py而不是setup.py。 configure.py生成一个make文件,您可以通过向configure.py传递--qmake选项来使用该文件构建pyqt并选择所需的qt库,该文件还具有不同的选项。我建议向pip维护者提交错误报告。


3
澄清一下:您仍然可以通过手动下载并按照其安装说明进行操作来构建此软件包。 - Thomas Wouters
@hector 应该使用pip安装,文件实际上来自riverbank。他们没有*nix二进制文件,只有Windows。顺便说一句,easy_install可以很好地处理它。 - Mike Ramirez
5
不,easy_install 也不知道如何处理它。 - the_drow

9

如果你使用的是Mac操作系统,你可以使用Homebrew

brew install pyqt

5
你可以选择使用ActivePython的二进制包管理器,安装PyQt4
$ pypm install pyqt4
The following packages will be installed into "~/.local" (2.7):
 pyqt4-4.8.3.0
Hit: [pypm-free.activestate.com] pyqt4 4.8.3.0
Installing pyqt4-4.8.3.0
$

只要您已经安装了PyPM,无需编译。

2

分享我的设置过程:

  1. 在您的项目文件夹上创建虚拟环境并激活:

    python3 -m venv venv source venv/bin/activate

  2. 使用pip安装PyQt5(注意:在Centos7上特别指定版本)

    pip3 install pyqt5==5.14


1

下载所需版本的PyQt后,您可以使用pip安装其目录。在Google中搜索您需要的版本。


0

我在我的树莓派3型号B(树莓派操作系统)上遇到了同样的问题,我使用apt-get解决了它。

这里是:

pip3 install --user pyqt5

sudo apt-get install python3-pyqt5

可选:

sudo apt-get install pyqt5-dev-tools

sudo apt-get install qttools5-dev-tools


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接