Is it possible to require PyQt from setuptools setup.py?(是否可以从 setuptools setup.py 中要求 PyQt?)
问题描述
我正在构建一个使用 PyQt 的小应用程序,并且认为在 setup.py 中声明该依赖项会很好.
I'm building a small app that uses PyQt and tought it'd be nice to declare that dependency in setup.py.
然而,根据这个博客(第一次在谷歌上搜索pyqt setuptools)说无法完成,最后一段这里 也不会尝试这样做.
However, according to this blog (first hit on google for pyqt setuptools) says it can't be done, and the last paragraph here doens't try to do it either.
想法?也许我应该切换到 PySide/" rel="noreferrer">PyPi?
Ideas? Perhaps I should switch to PySide which is on PyPi?
更新:
setup.py
中明显的 install_requires = [ 'pyqt >= 0.7' ]
给了我:
The obvious install_requires = [ 'pyqt >= 0.7' ]
in setup.py
gives me:
D:3rdBuildBotIconmy-buildboticonpython>setup.py test
running test
install_dir .
Checking .pth file support in .
C:Python26-32pythonw.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')
推荐答案
虽然接受的答案原本是正确的 Python Wheels现在提供一种无需从源代码编译即可安装 PyQt5 等 C 扩展包的方法.
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 目前在 Python3 上有多个平台的 PyQt5 的 .whl
文件,包括 MacOS X、Linux(任何)、Win32 和 Win64.例如,这是在 Mac 上的 Python3 上 pip 安装 PyQt5 时的输出:
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:
mfitzp@MacBook-Air ~ $ pip3 install pyqt5
Collecting pyqt5
Downloading PyQt5-5.6-cp35-cp35m-macosx_10_6_intel.whl (73.2MB)
100% |████████████████████████████████| 73.2MB 2.5kB/s
Collecting sip (from pyqt5)
Downloading sip-4.18-cp35-cp35m-macosx_10_6_intel.whl (46kB)
100% |████████████████████████████████| 49kB 1.8MB/s
Installing collected packages: sip, pyqt5
Successfully installed pyqt5-5.6 sip-4.18
如果您的目标是 Python3+PyQt5,那么在 setup.py
中将 PyQt5 指定为普通依赖项应该没有问题.
If you are targeting Python3+PyQt5 then you should have no problem specifying PyQt5 as a normal dependency in setup.py
.
这篇关于是否可以从 setuptools setup.py 中要求 PyQt?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是否可以从 setuptools setup.py 中要求 PyQt?


基础教程推荐
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 筛选NumPy数组 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01