Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
1  
    
thanks for the answers; in retrospect it should have been obvious seeing as I run python3 side-by-side with no problems :) –  d3vid May 5 '11 at 6:18
    
updated title to reflect that it applies to newer versions too –  d3vid May 5 '11 at 6:23
add comment

5 Answers 5

up vote 4 down vote accepted

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. :)

share|improve this answer
1  
thanks for the edit :) i'm new to unity so i'm not used to talking to people in terms of the new GUI –  Grant May 3 '11 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 –  d3vid May 5 '11 at 6:16
    
Or just click here for any newer version: apt.ubuntu.com/p/python2.6 . –  Agmenor Nov 11 '11 at 1:47
add comment

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.

share|improve this answer
    
it's good to point that out, thanks –  d3vid May 5 '11 at 6:13
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
add comment

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:

  1. 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
    
  2. 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
    
  3. Restart the shell:

    exec $SHELL
    
  4. Check that the installation is ok:

    ➜  ~  pyenv --version
    pyenv 0.4.0-20140110.1-14-g46a01b1
    
  5. 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
    
  6. Done. Now you may want to do pyenv rehash. Also use pyenv 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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.