是否可以从 setuptools setup.py 中获取 PyQt?
我正在构建一个使用 PyQt 的小型应用程序,并且认为最好在 setup.py 中声明该依赖项。
然而,根据这个博客(第一次在谷歌上搜索pyqt setuptools)说它不能完成,最后一段此处也不会尝试这样做。
有想法吗?也许我应该切换到位于 PySide /" rel="noreferrer">PyPi?
更新:
setup.py
中明显的 install_requires = [ 'pyqt >= 0.7' ]
给了我:
D:\3rd\BuildBotIcon\my-buildboticon\python>setup.py test
running test
install_dir .
Checking .pth file support in .
C:\Python26-32\pythonw.exe -E -c pass
Searching for pyqt>=4.7
Reading http://pypi.python.org/simple/pyqt/
Reading http://www.riverbankcomputing.com/software/pyqt/
Reading http://www.riverbankcomputing.com/software/pyqt/download
No local packages or download links found for pyqt>=4.7
error: Could not find suitable distribution for Requirement.parse('pyqt>=4.7')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
是的,PyQT 包没有使用 distutils / setup.py 进行安装,因此无法使用 easy_install 或 pip 安装。您需要手动下载并安装它。
这也意味着您不应该将其放入您的
requires
元数据中,因为 easy_install 和 pip 会尝试安装它并失败。我不知道PySide好不好,但它也没有setup.py,而且也拒绝使用easy_install/pip安装,所以不是一个好的选择。 :)
另一种选择是使用 distutils 重新打包 PyQt,但这可能需要大量工作。
Right, the PyQT packages are not using distutils / setup.py for it's installation, so they can't be installed with easy_install or pip. You need to download and install it manually.
That also means you should not put it in your
requires
metadata, as easy_install and pip then will try to install it and fail.I don't know if PySide is any good, but is also has not setup.py, and also refuse to install with easy_install/pip, so not a good option. :)
Another option is to repackage PyQt with distutils, but that may be a lot of work.
虽然由于现在可用的轮子(如@mfitzp建议),您可以
pip install pyqt5
,但不能通过install_requiressetup.py
要求它>。原因是setuptools
不知道如何安装pip
知道如何安装的轮子,而 PyQT5 只能作为 PyPI 上的轮子使用(没有源代码分发,即没有tar.gz
文件)。请参阅此电子邮件以及错误报告了解详细信息。While you can
pip install pyqt5
thanks to the now available wheels (as suggested by @mfitzp), it cannot be required fromsetup.py
viainstall_requires
. The reason is thatsetuptools
doesn't know how to install wheels whichpip
knows how to, and PyQT5 is only available as wheels on PyPI (there is no source distribution, i.e. notar.gz
file). See this email and that bug report for details.虽然接受的答案最初是正确的 Python Wheels 现在提供了一种安装 C 扩展包(例如 PyQt5)的方法,而无需编译从源头。
PyPi 目前在 Python3 上为多个平台提供了 PyQt5 的
.whl
文件,包括 MacOS X、Linux(任何)、Win32 和 Win64。例如,这是在 Mac 上的 Python3 上 pip 安装 PyQt5 时的输出:如果您的目标是 Python3+PyQt5,那么在
setup.py
中将 PyQt5 指定为正常依赖项应该没有问题。While the accepted answer was originally correct Python Wheels now provide a means to install C extension packages such as PyQt5 without the need for compilation from source.
PyPi currently has
.whl
files for PyQt5 on Python3 for multiple platforms, including MacOS X, Linux (any), Win32 and Win64. For example, this is the output when pip-installing PyQt5 on Python3 on a Mac:If you are targeting Python3+PyQt5 then you should have no problem specifying PyQt5 as a normal dependency in
setup.py
.Setuptools >= 38.2.0 现在知道如何安装轮子。< /strong> 因此,简单的答案是安装最新版本的 setuptools,并要求您的开明用户群也这样做。要在安装时强制使用 setuptools >= 38.2.0,请参阅其他地方的相关答案。
自从 setuptools 38.2.0 发布一年多以来,这个问题之前的所有答案都已经过时、公然错误,而且用处不大。
Setuptools >= 38.2.0 now knows how to install wheels. The trivial answer, therefore, is to install a recent version of setuptools and require that your enlightened userbase does so as well. To enforce usage of setuptools >= 38.2.0 at installation time, see this relevant answer elsewhere.
Since setuptools 38.2.0 was released over a year ago, all prior answers to this question are horrifyingly obsolete, blatantly wrong, and less than useful.