When I eventually upgrade to 11.04 I will need to install Python 2.6 for development purposes. The 11.04 default is 2.7. Can I just install the python2.6 package alongside the default python package? I don't want anything else to depend on it, I need it for only one purpose. I will be using Distribute and virtualenv to install any further dependencies for Python 2.6.
5 Answers
Run synaptic(through the application lens in unity or System -> Administration if you are using classic desktop )
search for python 2.6 in the filter at the top and mark it for installation by right clicking it, and selecting "Mark for Installation".
It should run alongside 2.7 fine as far as I'm aware, now when you need to use 2.6 invoke it directly, i.e with the command "python2.6 "
This should work, let me know if it doesn't though. :)
-
1thanks for the edit :) i'm new to unity so i'm not used to talking to people in terms of the new GUI– GrantMay 3, 2011 at 15:48
-
for anyone applying the question to an older version of Ubuntu or via the Gnome 2 desktop, Synaptic is available under System / Administration / Synaptic Package Manager May 5, 2011 at 6:16
-
Or just click here for any newer version: apt.ubuntu.com/p/python2.6 .– AgmenorNov 11, 2011 at 1:47
VirtualEnv is the definitely best way to have multiple python versions, even it it is the same interpreter but with different installed libraries. In each virtual environment you will run the selected python version. Every thing will be transparent.
BTW: you can find a repository with very old python version here: https://launchpad.net/~fkrull/+archive/deadsnakes/+packages
Maybe it will be useful for someone.
Yes, you can without any problems.
You can even do system wide installs using easy_install
. Just instead of invoking it directly, invoke it via python2.6 easy_install
.
You can use pyenv to do this too. I rather simple and also it allows you to switch versions and control your python enviroment. To install and use:
Install the dependencies of python, to prevent weird messages:
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev git
Install pyenv. Sadly this application doesn't have package that you could just apt-get away, but still it's easy to install:
mkdir $HOME/.pyenv cd $HOME git clone git://github.com/yyuu/pyenv.git .pyenv
the following is bash exclusive. If you use another shell you must modify the
.bashrc
entries.echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc echo 'eval "$(pyenv init -)"' >> ~/.bashrc
Restart the shell:
exec $SHELL
Check that the installation is ok:
➜ ~ pyenv --version pyenv 0.4.0-20140110.1-14-g46a01b1
Install python versions away:
➜ ~ pyenv install 2.7.6 Downloading Python-2.7.6.tgz... -> http://yyuu.github.io/pythons/1d8728eb0dfcac72a0fd99c17ec7f386 Installing Python-2.7.6... Installed Python-2.7.6 to /home/braiam/.pyenv/versions/2.7.6 Downloading setuptools-2.1.tar.gz... -> https://pypi.python.org/packages/source/s/setuptools/setuptools-2.1.tar.gz Installing setuptools-2.1... Installed setuptools-2.1 to /home/braiam/.pyenv/versions/2.7.6 Downloading pip-1.5.tar.gz... -> https://pypi.python.org/packages/source/p/pip/pip-1.5.tar.gz Installing pip-1.5... Installed pip-1.5 to /home/braiam/.pyenv/versions/2.7.6
Done. Now you may want to do
pyenv rehash
. Also usepyenv versions
, since this will show all the versions possible.pyenv local 2.7.6
will set the version of python used by the current directory and below to that version.
for testing purpose, you would also install it locally (or not) from the sources :
download the tarball source package. Python is really easy to compile. (the trick is in the altinstall
)
./configure --prefix="/home/me/python2.6"
make
make altinstall
then do
export PATH="/home/me/python2.6/bin":$PATH
export LD_LIBRARY_PATH="/home/me/python2.6/lib":$PATH
Plus you may want to play with virtualenv