My package only supports Python 3, enforced from setuptools
using python_requires='>3.6'
When I try to pip install from python 2, I get a vague error:
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.
When I run install with -vvv
, I see that pip is ignoring the py3 packages which is expected.
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.
Is there any way to get a better error message?
I see discussions in GitHub but there does not appear to be a workaround.
Here they are:
The workaround I went with is to remove python_requires
and then manually check it at the top
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
$ 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