我的软件包仅支持python 3,它是使用python_requires='>3.6'
从setuptools强制执行的
当我尝试从python 2 pip安装时,出现一个模糊的错误
ERROR: Could not find a version that satisfies the requirement mypackage (from versions: none)
ERROR: No matching distribution found for mypackage
这与我打错包装名称的错误相同,但不是很有帮助。
当我使用-vvv
运行install时,我发现pip忽略了预期的py3软件包。
Link requires a different Python (2.7.16 not in: u'>=3.6'):
https://mypypiindex (from https://mypypiindex) (requires-python:>=3.6)
我正在开发的软件包适用于我公司的大量开发人员,我想向他们说明解释器版本限制。
有什么办法可以得到更好的错误消息?
我在GitHub上看到了讨论,但似乎没有解决方法。
这里是:
答案 0 :(得分:0)
我要解决的方法是删除python_requires
,然后在顶部手动检查
import sys
# we used to use python_requires but we want a better
# error message for people trying to use python 2
MIN_PY_VERSION = (3, 6)
assert sys.version_info >= MIN_PY_VERSION,\
"ERROR: python version must be greater than {}".format(MIN_PY_VERSION)
当开发人员尝试使用不兼容的python版本进行安装时,将向他们显示
$ pip install .
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Looking in indexes: https://artifactory.local.mycompany.net/artifactory/api/pypi/pypi/simple
Processing XXX
ERROR: Command errored out with exit status 1:
command: /XXX/bin/python2.7 -c 'XXX'
cwd: /private/var/folders/t0/bpn6p6nn3jv_fmz9h_wdlld40003f0/T/pip-req-build-1YAoYX/
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/XXX/setup.py", line 11, in <module>
"ERROR: python version must be greater than {}".format(MIN_PY_VERSION)
AssertionError: ERROR: python version must be greater than (3, 6)
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
注意:如果您是从轮子上安装的,因为它们不运行setup.py
,因此该方法不起作用