Skip to content Skip to sidebar Skip to footer

How Do I Switch From Python 2.6 To 2.7 By Default

How do I switch from python 2.6 to 2.7 by default ls -l /usr/bin/python* lrwxrwxrwx 1 root root 9 Jan 27 12:36 /usr/bin/python -> python2.6 lrwxrwxrwx 1 root root 9 Jan 27

Solution 1:

A lot of Ubuntu packages use python. They also install modules in /usr/lib/pythonX.Y where (X.Y is your default python version).

The python packaging system only provides those modules for the default python.

If you change your default python, it would become your responsibility to provide those modules for the new version of python or else your system will break.

Therefore, unless you really know what you are doing (i.e. you are willing to port and maintain all those modules), I would strongly recommend not trying to change the default version of python.

Instead use virtualenv and virtualenvwrapper to allow you to switch versions at the user level.

Solution 2:

Create a folder in your home folder like .bin (or whatever you want)

Open your terminal configuration file (.bashrc , .zshrc ..) and modify your $PATH variable. like

export PATH=$HOME/.bin:$PATH

then put a symlink to there.

ln -s /usr/bin/python2.7 ~/.bin/python
ln -s /usr/bin/python2.7-config ~/.bin/python-config

with this way you don't have to change something systemwide.

otherwise you can change the global symlinks to change them system wide. But i can affect sth. you don't know.

The first method will be more stable & secure.

Post a Comment for "How Do I Switch From Python 2.6 To 2.7 By Default"