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?
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 thatpython is already in the newest version
.Second, you should usually prefer the Python modules packaged for
apt
from the repositories over those you get withpip
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: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:Another tip for you:
You should learn about and use
virtualenv
s, 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.