Ubuntu – How to install Python 3.3

python3software installation

I have downloaded Python 3.3 from the official site but no idea how to install it.

I'm using Ubuntu 12.04

Best Answer

Python 3.3 has been released on 29 September 2012, several months after Ubuntu 12.04 was released. It is included in Ubuntu 12.10 though as python3.3 package

If you want to install Python 3.3 on Ubuntu version which does not have it in its repositories, you have the following options:

Use a PPA

There's a PPA containing Old and New Python versions maintained by Felix Krull. See Luper Rouch's answer for installation instructions.

Compile Python from source

This is very easy and allows you to have multiple Python versions without messing with system python interpreter (which is used by a lot of Ubuntu own programs). On my dev machine I have literally dozens of different Python versions from 2.4 to 3.2 living happily in /opt.

we need C compiler and other stuff to compile Python

sudo apt-get install build-essential

SQLite libs need to be installed in order for Python to have SQLite support.

sudo apt-get install libsqlite3-dev
sudo apt-get install sqlite3 # for the command-line client
sudo apt-get install bzip2 libbz2-dev

Download and compile Python:

wget http://www.python.org/ftp/python/3.3.5/Python-3.3.5.tar.xz
tar xJf ./Python-3.3.5.tar.xz
cd ./Python-3.3.5
./configure --prefix=/opt/python3.3
make && sudo make install

Some nice touches to install a py command by creating a symlink:

mkdir ~/bin
ln -s /opt/python3.3/bin/python3.3 ~/bin/py

Alternatively, you can install a bash alias named py instead:

echo 'alias py="/opt/python3.3/bin/python3.3"' >> .bashrc

And this is it. Now you can have any Python version, even an alpha, or, say, to have a few copies of Python 3.3 compiled with different settings... not that many people need that though :)

Use pyenv

There's a software called pyenv which may help you to automate the procedure - what it essentially does is compile Python from source, installing it in your home directory. Its goal is to help you manage multiple Python versions.