简体   繁体   English

当我尝试使用不兼容的 python 版本安装 pip 时,如何获得更好的错误消息?

[英]How do I get a better error message when I try to pip install with an incompatible python version?

My package only support python 3, enforced from setuptools using python_requires='>3.6'我的 package 仅支持 python 3,使用python_requires='>3.6'从 setuptools 强制执行

When I try to pip install from python 2, I get a vague error当我尝试从 python 2 安装 pip 时,我收到一个模糊的错误

  ERROR: Could not find a version that satisfies the requirement mypackage (from versions: none)
ERROR: No matching distribution found for mypackage

This is the same error as if I had typo'd the package name which is not very helpful.这与我打错了 package 名称的错误相同,这不是很有帮助。

When I run install with -vvv , I see that pip is ignoring the py3 packages which is expected.当我使用-vvv运行安装时,我看到 pip 忽略了预期的 py3 包。

Link requires a different Python (2.7.16 not in: u'>=3.6'):
https://mypypiindex (from https://mypypiindex) (requires-python:>=3.6)

The package I am developing is for a large audience of developers at my company and I want to make it clear to them the interpreter version restriction.我正在开发的 package 面向我公司的大量开发人员,我想向他们说明解释器版本限制。

Is there any way to get a better error message?有没有办法获得更好的错误信息?

I see discussions in GitHub but there does not appear to be a workaround.我在 GitHub 中看到了讨论,但似乎没有解决方法。

Here they are:他们来了:

The workaround I went with is to remove python_requires and then manually check it at the top我使用的解决方法是删除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)

When the developer tries to install with an incompatible python version, they will then be presented with当开发人员尝试使用不兼容的 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.

NOTE: This does not work if you are installing from a wheel as they do not run setup.py注意:如果您从轮子安装,这不起作用,因为它们不运行 setup.py

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我尝试执行 pip 安装时出现错误 - I get and error when I try to do pip install 当我尝试使用pip install安装此软件包时,如何解决此错误? - How do I fix this error I'm getting when I try to install this package with pip install? 当我尝试使用 pip 安装软件包时出现错误 - When i try to install packages with pip i get an error 当我尝试使用 pip 安装“PyGObject”时出现错误 - When I Try To Install 'PyGObject' With pip I Get an Error 当我尝试通过pip安装BeautifulSoup时为什么会出现此错误? - Why do I get this error when I try to pip install BeautifulSoup? 当我尝试使用 pip 安装 python 模块时,会导致错误。 我该如何解决? - When I try to install python module using pip, it causes error. How can I fix it? 为什么我通过 pip、python 在版本 3.9.13 和 pip 在版本 22.2.1 上安装 ffmpeg-python 错误 - Why do I install ffmpeg-python error via pip, python on version 3.9.13 and pip on version 22.2.1 无法识别新的 Python 版本。 我安装了新的 python 版本,但是当我尝试安装软件包时出现错误 - New Python version not recognised. I installed the new python version but I get an Error when I try to install packages 当我尝试导入 facebook 先知时:pip 安装 fbprophet ...我总是收到此错误 - when i try to import facebook prophet: pip install fbprophet ... i alway get this error 如何在Python中使用try / catch获得更好的错误信息 - How can I get better error information with try/catch in Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM