Updating Python 3 to latest

How would I go about updating my Python 3 installation (which for 17.04 is 3.5) to the 3.6.1 - I naturally don’t want to remove 2.7 for system purposes…

But how do I go about upgrading past what is in the repos???

Thanks in advance…
Chris

With no disrespect meant, I suggest you don’t install Python to your system folders like suggested in the above link. Ubuntu MATE, like any other self-respecting complex Linux system, is heavily dependent on Python. Best to leave the system Python completely alone, as well as any of its packages.

The recommended way to handle Python is to leave the system version alone and install any Python versions on your home folder. And yes, this even includes installing again the current version of Python that exists already on your system, if you are interested in developing on python. Meaning on this case that you would have two pythons of the same version: one belonging to the system, which you never use or touch (except of course when Ubuntu MATE upgrade wants to upgrade it) and another for your purposes.

In other words, even if you are developing for a python version that comes with your Linux distro, you never use that. But instead install a duplicate version on your home folder.

Python Virtual Environments

So, for a correct and safe Python installation on Linux you use a Python virtual environment manager. Python virtual managers will help you install, manage and switch through multiple versions of python on your system without any of them ever having a chance of conflicting with your own system python and potentially corrupting it. Remember that most, if not all, modern fixed release distros are heavily dependent on python. Installing other python versions alongside it, or messing with the required packages, is a recipe for a type of disaster very hard to recover from.

My personal favourite is pyenv, a plugin for virtualenv that makes it much easier to use.

Instead of telling you how to install and use it, I’ll refer you to an excellent tutorial on the whole thing that you can find here.

I’ll be happy to assist you on anything concerning the installation and use of pyenv on Ubuntu MATE. And if you are a python developer, I may also furbish you with a few bash scripts of my own to make good use of the linux prompt and also extend further the usability of pyenv.

3 Likes

@marfig great post! Maybe something for the tutorial section?

1 Like

Thank you @orschiro.

I might do just that when I find the time. I do enjoy writing those and It wouldn’t be the first one on this forum. Right now, however, I’m in a little overwhelmed by life in general.

1 Like

Well, of course, no rush.

I was just thinking that maybe it was easy to move or copy your post over to the tutorial section of this forum. :slight_smile:

Sorry to take so long in getting back to you on this - but your tutorial was dead on! I was able to follow it and got everything setup just fine!!!

So once again, thanks for the advice! Super happy with the results!!!

1 Like

Here's two scripts you may like: https://bitbucket.org/krugar/ratscripts/src/6bee548994ae?at=master

Look for:
bash/ppenv. Prints the current python development environment
bash/gitprompt. Prints a one-line formatted output of the git status command

They come with their own man files and the wiki has full instructions on how to set them up.


Here's a typical semi-verbose output from ppenv, executed within a project directory pointing to local virtual python based on 3.5.2:

And here's a typical bash prompt that calls the gitprompt script when you move into a git project. On this case, showing you are currently on branch 'develop' and there are two staged files for commit, one changed file and one unstaged file:

1 Like