2

I'm on Ubuntu Mate 20.04. I'd like to install latest Python 3.8 on my system globally but I've noticed that it's the same Python install that is managed by the OS and therefore I'd like not to tweak it. For various reasons I need to work with exactly 3.8. I was thinking about installing it locally (e.g. on $HOME/.local) or even create a venv and sourcing the activation on every prompt but it seems to be just more confusing. Is there a safer way to achieve this?

This is not really the answer I was looking for. I'm talking about installing the same python version used by the system.

2 Answers2

1

'global' is a broad term. The system-wide installation that comes pre-packaged with ubuntu is located in the /usr/bin/ directory.

If you want to install the latest python version, one of the best ways is to install it from the source (with sudo). This way, it will be installed 'globally' but at the /usr/local/bin directory.

Now, you will have two versions of the python interpreter - it's possible to have both of them as python3.8.

However, they remain distinct. One of them can be mapped as the default system-wide interpreter by using update-alternatives.

Arnab De
  • 406
1

As suggested by @ArnabDe, you can install any version from source in /usr/local and have it separated from the system interpreter.

However given your requirements, I think pyenv is what you're looking for.

It let's you install any version you want and use it the default interpreter for your user only. I would especially advise against the update-alternatives part of the other answer as Ubuntu heavily relies on python and modifying the default system interpreter is likely to break a lot of things.