Question

I'm trying to install pip and virtualenv on a server (running Ubuntu 12.04.4 LTS) on which I have access, but I can only do it with sudo apt-get install (school politics). The problem is that althought I have run the sudo apt-get update command to update the packages list, I think it keeps installing old ones. After doing sudo apt-get install python-pip python-virtualenv, I do pip --version on which I get the 1.0, and virtualenv --version on which I get 1.7.1.2. These two version are quite old (pip is already in 1.5.5 and virtualenv in 1.11.5). I read that the problem is that the packages list is not up-to-date, but the command sudo apt-get update should solve this, but I guess no. How can I solve this? Thanks a lot!

Was it helpful?

Solution

apt-get update updates packages from Ubuntu package catalog, which has nothing to do with mainstream versions.

LTS in Ubuntu stands for Long Term Support. Which means that after a certain period in time they will only release security-related bugfixes to the packages. In general, major version of packages will not change inside of a major Ubuntu release, to make sure backwards-compatibility is kept.

So if then only thing you can do is apt-get update, you have 2 options:

  • find a PPA that provides fresher versions of packages that you need, add it and repeat the update/install exercise
  • find those packages elsewhere, download them in .deb format and install.

OTHER TIPS

If you really need to use the latest stable versions of Python packages, then do not use apt-get for installing Python packages and use pip instead. If you would use apt-get and later install the same packages by means of pip or (better not) easy_install or setup.py, you are likely to run into version conflicts wondering, why your python based commands are of unexpected versions, or even worse, why they do not work at all.

I try to follow this pattern:

1. system wide pip installation first

Using instructions from here: http://pip.readthedocs.org/en/latest/installing.html find get-pip.py script, download it and run as python script.

$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py
$ rm get-pip.py

2. use pip to install virtualenv system wide

this shall be as easy as:

$ sudo pip install virtualenv

3. (optional) install virtualenvwrapper - system wide or to user profile

$ sudo pip install virtualenvwrapper

and follow instructions for configuring it.

4. Since now, install inside your virtualenv environments

This shall prevent conflicts between various versions of packages.

You are free to update particular virtualenvs as you need one by one independently.

5. (optional) Configure installation cache directories for installation speed

There are method how to speed up repeated installation of packages, what comes handy if you get used using virtualenv often. For details see my answer: https://stackoverflow.com/a/18520729/346478

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top