There might be a day that your python is totally messed up and you won't be able to do any apt-get install. The situation is even worse if you haven't updated the server for a year or two and you are running Ubuntu Server 12.04. What would you do ? You will have a lot of chrome tabs open ! :)

  1. Recreate your sources.list: vi /etc/apt/sources.list and replace the content with the list from this generator. Make sure to make a backup first from the sources.list file.
  2. Compile Python 2.7 from source so the system uses that. Use this guide.
  3. Then try apt-get install python-dev. Then if it tells you there are unmet dependencies, look at the first dependency and do apt-get install on it.
  4. Then if you get an error message like:

Could not perform immediate configuration on 'python-minimal'.Please see man 5 apt.conf under APT::Immediate-Configure for details

Then do this:

apt-get install libglib2.0-dev # or the name of the package
apt-get upgrade
apt-get install -o APT::Immediate-Configure=false -f apt python-minimal 
  1. If everything went well, install pip, quick and dirty with easy_install pip (Use virtual python or something else if you prefer)

  2. Then do which pip to see if pip is in path. After that do pip install pycurl. That is the package that is necessary for system's package manager to work properly.

  3. Now test it for example by updating your php:

  sudo apt-get install software-properties-common
  sudo add-apt-repository ppa:ondrej/php5-oldstable
  sudo apt-get update
  sudo apt-get upgrade
  sudo apt-get install php5

Now you can close all the tabs that you have open on chrome :)


1: Tytus Kurek's blog: Could not perform immediate configuration of 'python-minimal' -

2: Compiling Python

3: Upgrading php from 5.3 to 5.4