3

I'm running Ubuntu 15.10. I installed Pyhon 2.7 through aptitude:

sudo apt-get install python

now I'm trying to install pip using this guide. I downloaded get-pip.py, then I tried:

sudo python get-pip.py

Installation worked fine, but I got these annoying warnings:

The directory '/home/administrator/.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/administrator/.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.

So I uninstalled all by the following command:

sudo python -m pip uninstall pip setuptools

And I tried a new installation without sudo:

python get-pip.py

but I got the following error:

OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pip'

How can I install pip (and wheels) in a proper way with caching enabled?

1 Answers1

5

First, Python 2.7 is pre-installed on every currently supported Ubuntu release already. So you would not have had to install it first. That's why apt-get has told you that python is already in the newest version.

Second, you should usually prefer the Python modules packaged for apt from the repositories over those you get with pip from PyPI, unless you rely on the features or bug fixes of the latest version. The repository versions are often more or less outdated, but proofed to be compatible with whatever other package that is requiring them.

So to install pip for Python 2, run this:

sudo apt-get install python-pip

In case this old pip version is not working for your needs, you can later simply get the latest version (without uninstalling the old one!) using this command:

sudo -H pip install --upgrade pip

Another tip for you:
You should learn about and use virtualenvs, virtual python environments. You can install Python modules in a viertualenv only without affecting other virtualenvs or the system. It's the safest way to prevent version incompatibilities and messing around with packages needed by the system and other programs.

Byte Commander
  • 110,243