pip2.7 in virtualenv: Python 2.7 reached the end of its life

I created a virtual environment using this command:

/usr/bin/python2.7 -m virtualenv venv

It mostly works, but using venv/bin/pip2.7 prints the following warning:

DEPRECATION: Python 2.7 reached the end of its life on January 1st,
2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021.
More details about Python 2 support in pip can be found at
https://pip.pypa.io/en/latest/development/release-process/#python-2-support
pip 21.0 will remove support for this functionality.

regardless of the command options, in both Ubuntu16 and Ubuntu20.

Including the above warning in a product is unacceptable and can only lead to confusion. (The warning is factually incorrect because Ubuntu20 supports Python 2.7 and pip2.7 through at least 2030. As with all popular programming languages, Python 2.7 is likely to be supported far into the future, until a newer compatible language comes along to supercede it.)

How do I disable the warning?

Update

It appears that this is a bug in pip versions 19+. How do I tell virtualenv to install pip 18?

  • 1

    Python (or pip) is Python while Ubuntu is Ubuntu. Why do you mix up Python’s lifespan with Ubuntu’s?

    – 




  • @hata Allow me to rephrase that as How are Python and Ubuntu lifespans connected? The answer is simple. Ubuntu 20 relies on Python2.7 and promises to support it through 2030. Therefore Python 2.7’s lifespan is at least through 2030.

    – 




  • 1

    I don’t think Python (Python Software Foundation) has some responsibilities for the policy of Ubuntu (Canonical Ltd.).

    – 

This installs pip 18.1 in a Python 2.7 environment without printing any warnings:

/usr/bin/python2.7 -m virtualenv --no-pip venv
git clone https://github.com/pypa/pip.git pip
(cd pip ; git checkout -b 18.1 18.1)
(cd pip ; ../venv/bin/python setup.py install)
venv/bin/pip list

it’s not a bug. It’s a very clear warning and message that you shouldn’t be using Python 2.

Python 2 is dead, long live Python 3.

Leave a Comment