Ubuntu 12.04 comes with python v 2.7.3
by default. I want to upgrade it to v 2.7.5
. I tried the instructions given in this question,
sudo apt-get install build-essential
sudo apt-get install libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
cd ~/Downloads/
wget http://python.org/ftp/python/2.7.5/Python-2.7.5.tgz
tar -xvf Python-2.7.5.tgz
cd Python-2.7.5
./configure
make
sudo make altinstall
The last command fails with the error:
...
Compiling /usr/local/lib/python2.7/xmlrpclib.py ...
Compiling /usr/local/lib/python2.7/zipfile.py ...
make: *** [libinstall] Error 1
How can I make this upgrade?
Installing from source can be done, of course, but I would be hesitant to upgrade my Ubuntu systems' python package from source for several reasons:
Doing so could break the system by doing a straight compile from source(I'm not exactly certain how Ubuntu customizes their Python package builds).
I would be concerned that there might be issues with using modules from the repositories going forward.
There is a PPA that looks active(the 2.7.x train was last built in April of this year), but the PPA doesn't yet have a 2.7.5 build. You may want to ping the maintainer and see what their plans are for future builds and if they are going to include one for 2.7.5. If possible, I would recommend this over installing from source. As with any new software, I would recommending building this out on a test system first.
Another option is to use a sandbox(
pyenv
) to run any new untested software package. A straight installation onto your system could adversely impact the operation of your machine.The package pyenv will allow one to install a non-system Python version on your box without impacting the main Python package installed on your machine( Again: Your system is dependent on the currently installed version of Python and upgrading it could break your system). Previously, Pythonbrew was recommended for isolating python packages from the system, but that has since been deprecated and superseded by the
pyenv
package.The
pyenv
package provides the following functionality:Installation
Check out pyenv into ~/.pyenv.
Add ~/.pyenv/bin to your $PATH for access to the pyenv command-line utility.
Zsh note: Modify your
~/.zshenv
file instead of~/.bash_profile
.Add pyenv init to your shell to enable shims and auto-completion.
Zsh note: Modify your
~/.zshenv
file instead of~/.bash_profile
.Restart your shell so the path changes take effect. You can now begin using pyenv.
Install Python versions into ~/.pyenv/versions. For example, to install Python 2.7.5, download and unpack the source, then run:
NOTE If you need to pass configuration options to build from source, please use CONFIGURE_OPTS environment variable.
Rebuild the shim binaries. You should do this any time you install a new Python binary (for example, when installing a new Python version, or when installing a package that provides a binary).