0

I had a Python version 2.7.6 installed on Ubuntu 14.04.

By mistake I ran:

sudo apt-get install python-dev

So it changed to Python 2.7.9.

Now I want to revert to 2.7.6. How can I do this?

2 Answers 2

2

A quick side-bar before we start breaking things... Is this really a problem? All 2.7.* versions should be compatible. The differences in release are basically just bug-fixes.

Update from comment: If you're seeing weird missing modules in virtualenvs, that's a common symptom of your system python version being updated. When you create a virtualenv, it copies the executable binary out to your virtualenv. If you replace the system version with a new version, any static bindings from the copy to other [python] system libraries might not align.

The quickest fix there is just re-creating the virtualenv. If you haven't already, this is a great opportunity to create a requirements.txt file in the root of your project. When you're recreated the base virtualenv you can just:

pip install -Ur requirements.txt

The same again to update packages.


The versions of the python2.7 package currently distributed show that Trusty only natively gets 2.7.6. The reason you have 2.7.9 is down to something you've done. Ie, it hasn't upgraded itself.

You've either:

  • Installed it somehow.

    The how really matters here. If you've manually dragged a newer python2.7-minimal over, reverting to the older version is probably not too hard with sudo apt-get install python2.7-minimal==2.7.6-8ubuntu0.2 (at the time of writing) but if you've installed a PPA, you'll need to purge that.

  • Upgraded to Vivid which ships 2.7.9.

    Check cat /etc/lsb-release. If you are, you're on an end of life system (dead, dangerous) so upgrade to Wily. That'll push you onto Python 2.7.10 but again, I don't consider that a problem in itself. If that really is for you, reinstalling 14.04 has just been added to your plans for the day.

5
  • actually my all virtual env and django are in python 2.7.6 so i need python 2.7.6 any other way is possible so plz tell me, without reinstalling ubuntu .
    – Kartik
    Apr 12, 2016 at 10:07
  • in my virtual env it return error like "ImportError: No module named datetime"
    – Kartik
    Apr 12, 2016 at 10:16
  • i tried with "sudo apt-get install pyton2.7-minimal==2.7.6-8ubuntu0.2" in terminal but it return error like "Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package pyton2.7-minimal= E: Couldn't find any package by regex 'pyton2.7-minimal=' "
    – Kartik
    Apr 12, 2016 at 10:30
  • Note obvious typo.
    – Oli
    Apr 12, 2016 at 10:31
  • Changing the system python also isn't going to affect which version is used in the venv, that's the point of them. They copy the current binary over on creation. I've had similar problems before (after upgrading Ubuntu) that I've fixed by recreating the virtualenv. Virtualenvs should be transitional (that is to say, store all your dependencies in a requirements.txt and recreating them is super-easy with pip install -Ur requirements.txt)
    – Oli
    Apr 12, 2016 at 10:34
0

You can have different python versions at the same time installed. Look at this site for details : https://geekforum.wordpress.com/2013/05/13/upgrade-downgrade-python/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .