Update System Python3

How would I update my system’s Python3 version? Right now it’s on Python 3.7, but I’d like to update that to a more recent version so I can do some Python development. I tried following the standard Python documentation’s update process but it doesn’t appear that I’m able to go outside the Purism repos.

I also tried downloading it as a AppImage and that let me run it but only using that AppImage, and I want my system itself to be updated and have it, not something I have to fire up an AppImage for every time.

I have an older Librem 15 laptop (bought in Spring 2018) and just did a general update now, and while that did bring my python version from 3.7.2 to 3.7.3, it’s still on 3.7 and I’d like to change that.

How would I do this? I tried searching the forum but didn’t see anything for this, so apologies if this has already been covered.

1 Like

Are you from PureOS Crimson?

1 Like

My two cents: don’t mess with the system Python version. I would suggest one of these three options (ordered by what I would consider easiest-to-hardest)

  1. Use Miniconda
  2. Use a container system like Podman and just run Python in the containers
  3. Download the Python source code and build it yourself

All of these are ways to try to keep all your Python development stuff isolated from the system stuff, so that you don’t inadvertently introduce some clashes and break things in the system version.

4 Likes

What taylor-williamc said, especially “don’t mess with the system Python”, except I would add:

  1. Use python’s venv “virtual environment”
    venv — Creation of virtual environments — Python 3.12.3 documentation
    (Easier is a subjective concept. venv is easier than anything conda to me.)

To be clear, not only “don’t mess with the system Python version”, but also “don’t mess with the system Python”. When using system python and using pip to install or update, be sure to use the --user option.

1 Like

Yeah, virtual environments are also key. Once the newer Python version has been installed, you should then use it to make virtual environments for each project you work on. (Mini)conda has its own version called conda environments, but they do the same thing.

You are definitely right about using --user if you are using the system-provided pip. However, as a follow-up note, you should not use the --user flag when you have a virtual environment active.

1 Like