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.

Well, as I say, I need to have 2 versions of python installed on my PC. The first must be the latest one in order to use youtube-dl, and the second must be the 2.7 version to use it for a course ( witch says we must not upgrad to get the same results ). I'm on Ubuntu 12.04. Can anyone propose me something ? ( no virtual machines please )

Thanks!

share|improve this question
    
Your version of Ubuntu? –  Skaperen Oct 3 '12 at 19:33
    
I have the 12.04 one –  Sam Oct 3 '12 at 19:37
    
They're separate packages, you can have them both installed without doing anything special. Run python to get Python 2, or python3 for Python 3. Programs should use the right version automatically. –  Thomas K Oct 6 '12 at 19:02
    
youtube-dl supports both Python 2 and 3. You don't need Python 3 to run the latest version of youtube-dl. –  J.F. Sebastian Feb 7 at 11:59
add comment

3 Answers

You can just install them alongside eachother.

sudo apt-get install python2.7 python3

I think by default Python 2.7 will be used (i.e. is symlinked to /usr/bin/python). You can change this by changing that symlink. Most Python programs will specify which version they need and use it automatically. This is not advised, as it is likely to cause programs to return errors.

share|improve this answer
6  
Personally, I would NOT recommend changing the /usr/bin/python symlink. Most Python 2 scripts use a #! /usr/bin/python hashbang, and changing the symlink will cause many of them to break. Use python when writing Python 2 scripts and python3 when writing Python 3 ones. –  InkBlend Oct 3 '12 at 20:02
    
Right. I wouldn't do that, I'm just saying that you can and that that's how it works installing them side-by-side. –  reverendj1 Oct 3 '12 at 20:28
    
Importantly, doing this will only get you Python 3.2 under 12.04. Currently, the newest version of Python is 3.3, and while this may be included in 12.10, it is included in the 12.04 repositories. –  user802500 Oct 15 '12 at 19:56
add comment

Look into virtualenv. You can install multiple versions of python, each in their own virtual environment, and then activate the one you want to use. Inside the virtual environment, you can install other tools as well.

virtualenv info

Here's another Stack Overflow thread on this

share|improve this answer
add comment

Many programs still use the older Python 2 whereas in Ubuntu 12.10 everything is slowly being ported over to the new Python 3 instead so that hopefully on release every program in the repository will use the newer version and you will only have that installed by default...

share|improve this answer
    
Out of curiosity, where did you find out that plugins were being ported to Python 3? I thought that they were just going to leave them in 2 (although in hindsight that assumption seems silly). Can I get a list of the ones that have been ported and the ones that have not? –  InkBlend Oct 3 '12 at 22:31
    
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.