Replacing a Python system is a great idea. Switching to a single release will probably not break your system, but who wants to take a chance? Installing a library for your Python system using easy_install can also lead to problems if they conflict with each other.
An alternative is to create Python from the source, install it in your home directory, and use virtualenv to create isolated environments in which you can install any libraries you need for this project using pip (which is the more modern equivalent to easy_install ).
For Python 2.7, if you want some “additional” parts of the standard library, which means creating a few more things. Here's a script (heavily paved from blog posts scattered all over the internet) that works for me on Debian "Squeeze" (stable at the time of writing):
#!/bin/bash -e # Setup sudo aptitude install build-essential mkdir -p ${HOME}/.local mkdir build-python cd build-python # Get sources ### Tcl/Tk <http://www.tcl.tk/software/tcltk/download.html> wget "http://downloads.sourceforge.net/project/tcl/Tcl/8.5.13/tcl8.5.13-src.tar.gz" wget "http://downloads.sourceforge.net/project/tcl/Tcl/8.5.13/tk8.5.13-src.tar.gz" ### Berkeley DB <http://www.oracle.com/technetwork/products/berkeleydb/downloads/index-082944.html> wget "http://download.oracle.com/berkeley-db/db-4.8.30.tar.gz" ### Python <http://www.python.org/download/> wget "http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz" # Build Tcl tar xzf tcl8.5.13-src.tar.gz cd tcl8.5.13/unix ./configure --prefix=${HOME}/.local make make install cd ../.. # Build Tk tar xzf tk8.5.13-src.tar.gz cd tk8.5.13/unix ./configure --prefix=${HOME}/.local make make install cd ../.. # Build Berkeley DB 4.8 tar xzf db-4.8.30.tar.gz cd db-4.8.30/build_unix ../dist/configure --prefix=${HOME}/.local/opt/BerkeleyDB.4.8 --enable-tcl --with-tcl=${HOME}/.local/lib make make install cd ../.. # Set compile flags export LDFLAGS="-L${HOME}/.local/lib -L${HOME}/.local/opt/BerkeleyDB.4.8/lib" export CPPFLAGS="-I${HOME}/.local/include -I${HOME}/.local/opt/BerkeleyDB.4.8/include" export CXXFLAGS=${CPPFLAGS} export CFLAGS=${CPPFLAGS} export LD_LIBRARY_PATH=${HOME}/.local/lib:${HOME}/.local/opt/BerkeleyDB.4.8/lib export LD_RUN_PATH=${LD_LIBRARY_PATH} # Build Python 2.7 tar xzf Python-2.7.3.tgz cd Python-2.7.3 ./configure --prefix=${HOME}/.local make make altinstall cd .. # Install virtualenv, pip and virtualenvwrapper curl http://python-distribute.org/distribute_setup.py | ${HOME}/.local/bin/python2.7 curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | ${HOME}/.local/bin/python2.7 ${HOME}/.local/bin/pip install virtualenvwrapper # Update ~/.bashrc echo 'export PATH="${HOME}/.local/bin:${PATH}"' >> ${HOME}/.bashrc echo 'export WORKON_HOME="${HOME}/.local/virtualenv"' >> ${HOME}/.bashrc echo 'export VIRTUALENVWRAPPER_PYTHON="${HOME}/.local/bin/python2.7"' >> ${HOME}/.bashrc echo 'export VIRTUALENVWRAPPER_VIRTUALENV="${HOME}/.local/bin/virtualenv"' >> ${HOME}/.bashrc echo 'export VIRTUALENVWRAPPER_VIRTUALENV_ARGS="--python=python2.7"' >> ${HOME}/.bashrc echo 'source ${HOME}/.local/bin/virtualenvwrapper.sh' >> ${HOME}/.bashrc # Finish ... cd .. echo -e "\n\n ... Done!"
This script will ask for your password to install GCC, etc., if necessary, and then take the time to build everything - about 25 minutes on my (ancient) machine and (terrible) internet connection. If you pay attention, on some you will see the following scroll message:
Python build finished, but the necessary bits to build these modules were not found: bsddb185 dl imageop sunaudiodev To find the necessary bits, look in setup.py in detect_modules() for the module name.
These four modules are archaic and / or obsolete, so you do not need to worry about them. If other modules are mentioned in the message, this means that some necessary library is not installed on your system. You can still run Python if that happens, but you cannot import these modules. Scream in the comments if you are affected by this and I will update the script accordingly.
Once this is successfully completed, you need to specify .bashrc :
$ source ~/.bashrc
... and you can run your newly compiled Python ...
$ python2.7 Python 2.7.3 (default, Nov 17 2012, 02:00:26) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
... create virtualenv to work in ...
$ mkvirtualenv my_env $ python Python 2.7.3 (default, Nov 17 2012, 02:00:26) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
... install libraries in it ...
$ pip install beautifulsoup4
... etc.
To exit virtualenv:
$ deactivate
To re-enter it later:
$ workon my_env
See the pip and virtualenvwrapper documentation for more details.