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

wonton

My package only support 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:

wonton

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

I get and error when I try to do pip install

I get this error when I try to install

Install scrapy ERROR - When I try to install scrapy I get the following error that I do not know how to fix it:

When I try and run pyspark.cmd I get the error message "find: 'version': No such file or directory"

Why do I get error "Could not find a version that satisfies the requirement scipy==1.5.3" when running "pip install -r requirements.txt"?

How do I install packages with pip when there are multiple Python versions?

Why do i get this error when I try installing autopep8 using pip?

Error when I try to install Dlib with pip. macOS

Pip not working when I try to install Pygame for Python 3.6 [Outdated]

Why do I get an error message of NoneType object is not callable when I try to call this function?

I get a syntax error when I try to send a discord message

how do i install pip on python 3.5.2?

how do I install pip/enable in python

Python/Terminal - Why am I getting this error message when I try to get user input

Error I get when I try install IDE Anjuta

Why I get error when I try to install pyaudio?

I encounter this error when I try 'pip install StyleFrame', any idea what this error is about?

How do I get around this annoying error message? (Python 3.6.1)

Python / pip, how do I install a specific version of a git repository from github (what is the correct url)?

How can I install an apt-get/pip package for use by a particular Python version?

Why do I get an error for "__CrtGetFileInformationByHandleEx " when I try to compile

How do I solve the issue when I get "pip isn't recognized" error in Django virtualenv?

How do I download always the latest version of the programs when I use apt-get install [program]?

How do I use a Try and Exception to raise an error with a print message in Python?

Why does pip try to install an incompatible version of a library in a python2 virtualenv?

Why do I get this error when I run 'bower install'?

Why do I get a message saying "Object is not a function" when I try to do an apply?

Why do I get error when try to convert Carbon to DateTime?

I get an error when I try to install my project packages with npm i

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    pump.io port in URL

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    flutter: dropdown item programmatically unselect problem

  14. 14

    How to use merge windows unallocated space into Ubuntu using GParted?

  15. 15

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  16. 16

    Nuget add packages gives access denied errors

  17. 17

    Svchost high CPU from Microsoft.BingWeather app errors

  18. 18

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  19. 19

    12.04.3--- Dconf Editor won't show com>canonical>unity option

  20. 20

    Any way to remove trailing whitespace *FOR EDITED* lines in Eclipse [for Java]?

  21. 21

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

HotTag

Archive