On 2018-08-28 20:10, Michael F. Stemper wrote: > 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@host$ pip --version > pip 9.0.1 from /home/user/.local/lib/python2.7/site-packages (python 2.7)
Apparently, you did it the "right" way before: installing anything system-wide with pip that has already been installed with distribution packages is fairly likely to break. Installing a newer pip in your home directory should normally work fine. Opinions differ, but personally I *never* use "sudo pip": use "pip install --user" instead. This installs into ~/.local rather than /usr/local. i.e.: try python -m pip install --upgrade --user pip If that works, see if python -m pip --version and pip --version work and show the same thing. If the latter doesn't work or shows an old version, you may have to make sure ~/.local/bin/pip has priority over /usr/bin/pip (e.g. by putting ~/.local/bin/ near the front of your $PATH) If things break, you now know how to undo the damage thanks to Larry ;-) Also, PLEASE use Python 3. Still using Python 2 today is like still using Windows XP in early 2013. https://pythonclock.org/ -- Thomas > user@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@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@host$ pip --version > pip 9.0.1 from /home/user/.local/lib/python2.7/site-packages (python 2.7) > user@host$ > > Sure enough, no change. Given the file permission error, I figured > that I needed root privileges, so I tried again: > > user@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@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@host$ > > Well, even though it said "Successfully installed", it appears to > not have done so. > > Trying again with sudo's -H option: > > user@host$ sudo -H pip install --upgrade pip > Requirement already up-to-date: pip in > /usr/local/lib/python2.7/dist-packages (18.0) > user@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@host$ > -- https://mail.python.org/mailman/listinfo/python-list