5

I'm looking to pick up some programming skills and after looking into it a bit, I came across an article that recommended that I learn Python as a way of getting started at programming before moving on to other languages. I realize Python 2.x.x is preinstalled in Ubuntu, but I was wondering if it's possible to upgrade to Python 3.x.x as the site's documentation seems to indicate that 3.x.x is where the language is going in the future.

Failing that, how do I update Python 2.7.6 to 2.7.8?

3
  • 1
    If you are just starting with programming the python version will not make any difference, just use what you have installed.
    – Robot Mess
    Aug 28, 2014 at 7:35
  • 2
    For the benefit of those new to Python: The difference from 2.7.6 to 2.7.8 or 3.4.0 to 3.4.1 is not likely to matter much for you (and I think that's what Robot Mess means. But Python 2.y.z and Python 3.y.z are quite different languages. Even a typical Python 2 hello world program won't run with Python 3 as the interpreter. Aug 28, 2014 at 12:56
  • @EliahKagan This. Very good point. Besides the answer should be an answer to the question. Because I, who have programmed Python in the past am looking at how to install Python 3.3 on Kubuntu 14.04 (too) so I can learn Django using the latest code base. Nov 24, 2014 at 23:29

3 Answers 3

10

According to the package listing, Ubuntu 14.04 comes with Python 3.4 installed by default. Run python3 if you want python3.x.x (or python3.4 if you want python3.4.x).

Until most components have been migrated to Python 3, both 2.7.x and 3.x will be available on Ubuntu, with python being python2.

Python 2.7.8 isn't available in the official repositories. However, there's a PPA available: Old and New Python versions. See What are PPAs and how do I use them? to understand how to use PPAs. Also note that while the version in Ubuntu 14.04 may remain 3.4.0 for sometime, the devs will be backporting fixes from 3.4.1.

3
  • Great! I have 3.4.0. Would it be necessary to update to 3.4.1 (the latest version)? How would I go about that?
    – Lucas W
    Aug 28, 2014 at 5:16
  • 1
    @LucasW Unless you're programming on the cutting edge of Python, nope. If you do want to, you might have to compile from source. The PPA linked in the updated answer doesn't even have it. Also see askubuntu.com/q/474108/158442
    – muru
    Aug 28, 2014 at 5:18
  • If you want to exclusively use python3, you could alias python3 as python. You could still run python2 if you wanted it (or call /usr/bin/python directly) but by default it would use python3. I found it was easier to change than messing around with alternatives.
    – Holloway
    Aug 28, 2014 at 10:31
2

pyenv seems the way to go if you want to play with more than just the distribution's supplied version of Python 2.x and the supplied version of Python 3.x.

It let's you install many different Python versions side-by-side and choose between them. The installation happens inside a hidden directory in your home directory so you do not have to be root, you cannot disturb other people using other accounts (if there are any on your machine) and the "main" installation is always safe and secure and will not be changed or overridden in any way.

https://github.com/yyuu/pyenv#installation

0

Besides pyenv (as Peter Lund suggests), or a PPA (as muru suggests), or building from source and installing into /usr/local, if you decide you need another version of Python 3, you can use Conda (which is now suggested by the maintainer of that PPA).

Like pyenv, Conda facilitates creating and managing multiple separate Python installations on the same system. You'll likely want to choose Anaconda over Miniconda if you haven't used Conda before. (If you have used Conda before, then you may still often choose Anaconda; the choice is then a technical one made mainly based on the nature of your specific task.)

The Anaconda installer is available here. For more information on Anaconda, I recommend:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .