So how do you install later versions of python without impacting the system default version - which is required for all sorts of vital system services?
The trick is to use the prefix and altinstall options when building the new version of python. Make sure you have libsqlite3-dev and libssl-dev installed or Sqlite3 and SSL support won't be compiled in.
cd ~/src
wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
tar -jxvf Python-2.7.2.tar.bz2
rm Python-2.7.2.tar.bz2
cd Python-2.7.2/
./configure --prefix=/opt/python2.7
make
sudo make altinstall
sudo ln -s /opt/python2.7/bin/python2.7 /usr/bin/python2.7
You (and the system) will continue to use the old version by calling python, and you can use the new version by calling python2.7.
So to install sqlite3 support for python2.7 for instance:
cd ~/src
wget http://pysqlite.googlecode.com/files/pysqlite-2.6.3.tar.gz
tar -xzf pysqlite-2.6.3.tar.gz
rm pysqlite-2.6.3.tar.gz
cd pysqlite-2.6.3/
sudo python2.7 setup.py build_static install
Exactly what I was looking for, easy and simple, cheers!
ReplyDeleteExactly what I was looking for(2)
ReplyDeletethx a lot
Greg, thanks for guide. How would you uninstall it correctly? If doesn't affect to the system it's OK just wipe out link and python2.7 folder, right?
ReplyDeleteRemoving the source directory doesn't get rid of that version of Python - the cleanest way to do that is using the make tool to uninstall.
ReplyDeleteGo back to the source directory (~/src/Python-2.7.2/ in the example above) and enter "sudo make uninstall". Then you can remove the source directory, and that version of Python is now history.
This comment has been removed by the author.
ReplyDeleteThanks a lot!
ReplyDeleteOnly one remark: for sqlite3 in Python2.7.5 my system (Debian 6) required installing libsqlite3-dev.