0

I have a system I upgraded several Ubuntu versions, now I seem to have multiple versions of pip:

$ whereis pip3
pip3: /usr/bin/pip3 /usr/local/bin/pip3 /usr/local/bin/pip3.5 /usr/local/bin/pip3.4 /usr/share/man/man1/pip3.1.gz

When I enter "pip3" I get the result:

...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 3088, in <module>
    @_call_aside
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3072, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3101, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 576, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 589, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 778, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==8.1.1' distribution was not found and is required by the application

However when I run /usr/bin/pip3 (the one I can see Synaptic shows as the one in the installed python3-pip package) I get no error, a list of arguments to use. So what's the best way to uninstall all the older pip-references on the system?

0

The easiest way to solve your current problem is to do sudo rm /usr/local/bin/pip*.

The use of pip executable files can you get you in a weird state so many people now use the form of python3 -m pip instead of pip3. The problem crops up when you have multiple versions of Python installed on your system (it looks like you have Python 3.4 and 3.5) as each then has it's own copy of the pip module. pip also installs itself into /usr/local/bin/ as its specific version (e.g. /usr/local/bin/pip3.5) as well as /usr/local/bin/pip3 + /usr/local/bin/pip. Depending on which version gets updated, these executables don't get synced.

If you need the newest version of pip, do sudo /path/to/python3 -m pip install --upgrade pip, delete /usr/local/bin/pip + /usr/local/bin/pip3, then create a symlink using sudo ln -s /usr/local/bin/pip3.<VERSION> /usr/local/bin/pip3.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.