How do I update Python safely?

Details of what follow may be inaccurate…

A few years ago, I was running Linux on my laptop and I wanted to upgrade my python installation, or maybe it was pip that I wanted to update. In any case, I ran a built-in update command and that TOTALLY BORKED my entire system, or at least everything that had anything to do with Python. I hopped into an IRC chat and asked and was basically told I was an idiot for using the built-in updater instead of using whatever the OS wanted to use to update it.

So, what is the safest way for me to update Python? I think it is currently configured as it is installed. I see in /usr/bin/python the only versions available are 2.7 and 3.6. I have an application I want to update on the Rockstor server, but updating it any further than it currently is updated requires Python 3.7 or later.

@Noggin Hello again.
Re:

This is not really Rockstor related, but the best way to think about this is that the OS supplied Python is for the linux OS; and all it’s associated programs. In a Rockstor install (a customized openSUSE) we currently use these OS supplied Python versions directly ourselves Py2.7 in git master branch (stable rpm) and Py3.6 in git testing (soon to be next testing rpm/phase).

If you have a program that requires a new Python that those offered by the OS, you are best advised to setup a venv for that program specifically. Rockstor actualy does this, but does not yet incorporate the Python interpreter as currenty 2.7 and 3.6 work for us our our parent OS.

You may find within the openSUSE OS other Python interpreter packages available - they are made available for your situation, and are designed to stand along side the existing 2.7 & 3.6 versions. What you did years ago was use a non OS tool to update the OS Python version. That would not go well give large swayths of the OS depend on certain Python versions - hence the OS still using the already EOL 3.6 for example.

Another entire angle on this is to just use docker - that is what our Rock-ons do. Docker allows an entire other OS of sorts to be hosted by Rockstor’s base OS. You are then not limited to what the specific host OS offers re Python etc.

So in brief, never mess with the OS’s Python, if it can server you great, if not use a docker container to host your own entire OS environment, with whatever python version or whatever anything else you need. An older approach was to use virtual machines for such requirements.

Incidentally all of the more recent openSUSE Leaps are soon to offer Python 3.11 as a package.

Check out, via zypper, what is currently offered on you OS version regarding Python versions. 3.7 may be there already. But don’t uninstall 2.7 or 3.6 - hence using the parallel versions arranged by the OS developers and not micro-managing the OS yourself.

Hope that helps, at least for some context.

2 Likes