How to correctly avoid the "You are running Setuptools on Python 2, which is no longer supported" message while using Python 2?

7,799

We need to follow the recommendation in the last two lines of output:

You are using pip version 8.1.1, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

So we need to run

pip2 install --upgrade --user pip

and then logout and login back, then follow the other recommendation:

Setuptools using pip 9.x or later or pin to setuptools<45 in your environment.

pip2 install --user "setuptools<45"

After this any installation of pip2-packages will result in the following message:

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. 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

Share:
7,799

Related videos on Youtube

N0rbert
Author by

N0rbert

Updated on September 18, 2022

Comments

  • N0rbert
    N0rbert almost 2 years

    I have just installed Ubuntu 16.04 LTS on fresh system.
    I need to run some Python 2 stuff on it.

    So I did the following:

    $ pip2
    The program 'pip2' is currently not installed. You can install it by typing:
    sudo apt install python-pip
    $ sudo apt-get install python-pip
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following additional packages will be installed:
      libexpat1-dev libpython-all-dev libpython-dev libpython2.7 libpython2.7-dev python-all python-all-dev python-dev python-pip-whl python-setuptools
      python-wheel python2.7-dev
    Suggested packages:
      python-setuptools-doc
    The following NEW packages will be installed:
      libexpat1-dev libpython-all-dev libpython-dev libpython2.7 libpython2.7-dev python-all python-all-dev python-dev python-pip python-pip-whl
      python-setuptools python-wheel python2.7-dev
    0 upgraded, 13 newly installed, 0 to remove and 0 not upgraded.
    Need to get 30.7 MB of archives.
    After this operation, 48.3 MB of additional disk space will be used.
    Do you want to continue? [Y/n] y
    ...
    

    And then I started to use pip2:

    $ which pip2
    /usr/bin/pip2
    $ pip2 install --user jsonmerge
    ...
    

    and then it failed:

    $ pip2 install --user zipp
    /home/xenial/.local/lib/python2.7/site-packages/pkg_resources/py2_warn.py:22: UserWarning: Setuptools will stop working on Python 2
    ************************************************************
    You are running Setuptools on Python 2, which is no longer
    supported and
    >>> SETUPTOOLS WILL STOP WORKING <<<
    in a subsequent release (no sooner than 2020-04-20).
    Please ensure you are installing
    Setuptools using pip 9.x or later or pin to `setuptools<45`
    in your environment.
    If you have done those things and are still encountering
    this message, please comment in
    https://github.com/pypa/setuptools/issues/1458
    about the steps that led to this unsupported combination.
    ************************************************************
      sys.version_info < (3,) and warnings.warn(pre + "*" * 60 + msg + "*" * 60)
    Collecting zipp
    Installing collected packages: zipp
    Exception:
    Traceback (most recent call last):
      File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 209, in main
        status = self.run(options, args)
      File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 335, in run
        prefix=options.prefix_path,
      File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 732, in install
        **kwargs
      File "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 837, in install
        self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
      File "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 1039, in move_wheel_files
        isolated=self.isolated,
      File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 346, in move_wheel_files
        assert info_dir, "%s .dist-info directory not found" % req
    AssertionError: zipp .dist-info directory not found
    You are using pip version 8.1.1, however version 20.0.2 is available.
    You should consider upgrading via the 'pip install --upgrade pip' command.
    

    (the PyPi packages above are given as examples, I have seen this problem on systems with other packages from PyPi).

    How should I fix this problem in correct way?