Search code examples
pythonpython-3.xpipdebiandebian-stretch

Unable to use pip3 after migrating to debian Strech


After upgrading Debian, I can't use pip anymore (would like to use it to install pipenv and thus properly manage my virtualenvs…).

I installed pip3 with this command:

apt-get install python3-pip

Here is how pip3 complains:

$ pip3

Traceback (most recent call last):
  File "/usr/local/bin/pip3", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 78, in <module>
    raise RuntimeError("Python 3.3 or later is required")
RuntimeError: Python 3.3 or later is required

This is lead by this check in /usr/lib/python3/dist-packages/pkg_resources/__init__.py:

if (3, 0) < sys.version_info < (3, 3):
    raise RuntimeError("Python 3.3 or later is required")

But:

$ python3 --version

Python 3.5.3

And:

$ python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.version_info
sys.version_info(major=3, minor=5, micro=3, releaselevel='final', serial=0)
>>>

It seems like pip3 is confusing between Python 2 and Python 3 both installed on my debian server.

Have you ever faced this issue?


Solution

  • Just do a python3 -m pip install -U --force-reinstall pip.

    Thank you Knud Larsen!