Broken pip

Michael F. Stemper michael.stemper at gmail.com
Tue Aug 28 14:10:53 EDT 2018


I'm trying to upgrade my pip on Ubuntu 16.04. I appear to have
buggered things up pretty well. (Details follow) Any suggestions
on how to undo this and get everything back to proper operation?

Based on the information that I found at:
<https://github.com/pypa/pip/issues/3776>, I did the following:

user at host$ pip --version
pip 9.0.1 from /home/user/.local/lib/python2.7/site-packages (python 2.7)
user at host$ pip install --upgrade pip
Collecting pip
  Downloading
https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl
(1.3MB)
    100% |████████████████████████████████| 1.3MB 453kB/s
Installing collected packages: pip
  Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
      Successfully uninstalled pip-9.0.1
  Rolling back uninstall of pip
Exception:
Traceback (most recent call last):
 [snip error traceback]
    mkdir(name, mode)
OSError: [Errno 13] Permission denied:
'/usr/local/lib/python2.7/dist-packages/pip'
You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
user at host$ pip --version
SError: [Errno 13] Permission denied:
'/usr/local/lib/python2.7/dist-packages/pip'
You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
user at host$ pip --version
pip 9.0.1 from /home/user/.local/lib/python2.7/site-packages (python 2.7)
user at host$

Sure enough, no change. Given the file permission error, I figured
that I needed root privileges, so I tried again:

user at host$ sudo pip install --upgrade pip
[sudo] password for user:
The directory '/home/user/.cache/pip/http' or its parent directory is
not owned by the current user and the cache has been disabled. Please
check the permissions and owner of that directory. If executing pip with
sudo, you may want sudo's -H flag.
The directory '/home/user/.cache/pip' or its parent directory is not
owned by the current user and caching wheels has been disabled. check
the permissions and owner of that directory. If executing pip with sudo,
you may want sudo's -H flag.
Collecting pip
  Downloading
https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl
(1.3MB)
    100% |████████████████████████████████| 1.3MB 442kB/s
Installing collected packages: pip
  Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
      Successfully uninstalled pip-9.0.1
Successfully installed pip-18.0
user at host$ pip --version
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
user at host$

Well, even though it said "Successfully installed", it appears to
not have done so.

Trying again with sudo's -H option:

user at host$ sudo -H pip install --upgrade pip
Requirement already up-to-date: pip in
/usr/local/lib/python2.7/dist-packages (18.0)
user at host$ pip --version
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
user at host$

-- 
Michael F. Stemper
Galatians 3:28



More information about the Python-list mailing list