Ubuntu – Need to have 2 versions of Python without using a VM

pythonpython-2.7python3

I need to have 2 versions of Python installed on my PC. The first must be the latest version in order to use youtube-dl, and the second must be the 2.7 version for a course that says we must not upgrade to get the same results.

I'm on Ubuntu 12.04. How can I have two different versions of Python without using virtual machines?

Best Answer

  • 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.

    Changing the symlink is not advised, as it is likely to cause programs to return errors.