πŸ‡ΊπŸ‡¦ We stand with Ukraine! πŸ‡ΊπŸ‡¦

I got the Upgrade Blues

Me: I'd like to 3D print something.

OctoPrint: There's a new version of OctoPrint! You should upgrade!

Me: OK

OctoPrint: Upgrade complete. WARNING: You're using Python 2.x, which is guaranteed to break at the most inopportune moment imaginable. Upgrade to Python 3.x, and then run octoprint-upgrade-script.py to configure OctoPrint to use Python 3.

Me: But I already have Python 3.

OctoPrint: You have Python 3.5.1. You need Python 3.6 or later.

Me: Internet, how do I upgrade Python 3?

Internet: sudo apt-get install --update python3

Me: sudo apt-get install --update python3

Internet: You already have the latest version for Raspberry Pi (3.5.1).

Me: Internet, how do I upgrade Python 3.5.1 on a Raspberry Pi?

Internet: Uninstall Python 3.5.1 and build the latest version from source.

Me: sudo apt-get remove python3

Me: wget ... tar ... configure ... make ... blahblahblah

Raspberry Pi: Success. (Disregard the 5,000-or-so warning messages when building Python.)

Me: python3 octoprint-upgrade-script.py

Script: Error: Module "requests" not found.

Me: python3 -m pip install requests

Python: Can't download requests because the Python SSL module isn't available.

Me: Internet, how do I install the Python SSL module?

Internet: apt-get install these_25_packages

Me: apt-get install these_25_packages

Raspberry Pi: Success.

Me: python3 -m pip install requests

Python: Still no SSL module.

Me: Internet, what's the deal?

Internet: Oh, you have to install these_25_packages before building Python, and then rebuild Python.

Me: Linux, seriously, this is why people still use Windows.

4 Likes

I would like to note that the upgrade script method is only recommended for OctoPi 0.17 installs - which come with Python 3.7.3 - and newer/equivalent. If the latest version of Python installed on your system is too old (I think you may have OctoPi 0.16 or Debian 9 equivalent) then the recommended route on the FAQ for upgrading is to take a backup in OctoPrint and flash a newer OS image, for example OctoPi 0.18 which uses Python 3 out of the box.

Installing Python from source is a pain and so I commend you for attempting it!

Edit: also, that's a well told story

You made the mistake of doing an upgrade at a time where you wanted to accomplish something else. Always set aside a time to do upgrades for any software so that you have time to troubleshoot any issues or simply roll back.

As @Charlie_Powell said you're likely on a pretty old version of OctoPi. It would definitely be nice if it were easier to upgrade OctoPi versions like you can with Ubuntu but the process of backup and re-flash is so quick it's not worth the time to develop or even run.

Me: Linux, seriously, this is why people still use Windows.

OctoPrint can be installed/run on Windows, though I'm not sure if it's any easier than OctoPi... The reason you can't simply upgrade to Python to 3.7.x is because a lot of system services and tools were only tested with Python 3.5.x on that particular version you are running. Upgrading Python would likely create havoc across the board. Usually you would eventually update your distribution(OctoPi) version but for reasons mentioned above it's not really worth the effort over re-flashing.

I'd also like to note, the "Linux" instructions for migrating from Python2 to Python3 using the upgrade.py script are not really "Linux" oriented. But, rather Distro Centric - specifically Debian based.

If you're on an rpm centric distro - you'll have to read through the upgrade script, verify manually all pre-requisites are met and then comment out all the checks and re-run the script.

Or better yet, just note what it does and do it all manually. It can be made to complete, but only by pithing out the goodies.

After about an hour of flailing about, I have 1.7.0 on Python 3.9.7 on Fedora 34 without having to re-install anything. It's running great!

Good point there, @Charlie_Powell might want to update the notes for that. Luckily the majority of installs are on OctoPi and anything else is custom so the user should be able to do exactly what you did @WyoHam.

Thanks for the responses (and I'm glad you enjoyed the story; I had fun writing it).

@Charlie_Powell :

the recommended route is to take a backup in OctoPrint and flash a newer OS image, for example OctoPi 0.18 which uses Python 3 out of the box.

In the end, I took this advice and re-imaged with the latest OctoPi, which is an optional build in Raspberry Pi OS. Relatively smooth path with a successful outcome, and I'm now up and running again. Thank you!

@WyoHam:

the "Linux" instructions for migrating from Python2 to Python3 using the upgrade.py script are Distro Centric - specifically Debian based.

Good point. Of course, Raspberry Pi OS is a Debian fork, but I understand that the divergence might be substantial enough to break the script.

Incidentally, a script that is specific to Debian and not RPi OS seems like an odd choice, given the popularity of the RPi Zero / 3(B)(B+) / 4 among devices running OctoPrint.

You'll have to read through the upgrade script, verify manually all pre-requisites are met and then comment out all the checks and re-run the script. Or better yet, just note what it does and do it all manually.

In general, I am leery of any overly complicated process like this. I'm at a point in life where I have plenty of experience to babysit a build process and to resolve easy-to-moderate issues, but I simply don't have the time (or patience) to do so. I have several ambitious projects waiting on 3D prints, and I've already spent too much time on this OctoPrint upgrade as it is. Anything that looks like a potential time sink - indeterminate in both duration and outcome - is a landmine that I'd like to avoid.

@kantivelong:

you're likely on a pretty old version of OctoPi

No - I've upgraded OctoPrint with each incremental release. I don't recall seeing this warning about Python in previous updates. My version of Python 3.x was old (as Charlie mentioned), but not OctoPi.

You made the mistake of doing an upgrade at a time where you wanted to accomplish something else. Always set aside a time to do upgrades for any software so that you have time to troubleshoot any issues or simply roll back.

First - I've previously upgraded OctoPrint several times, and each one required about 30 seconds of patching and an OctoPrint reboot. I don't even think I had to reboot the RPi OS. So I didn't expect that this upgrade would be any different.

Second - both macOS and Windows have relatively graceful upgrade paths that never leave the OS in an unstable state. Even critical updates to core system components are handled well; the updated components are placed in a staging area, and the user can choose when to reboot. (Of course, Windows has some obnoxious tendencies to reboot without user consent, but that's an issue of bad UX design issue, not a technical deficiency.) I submit to you that Linux is way behind the pack in this regard.

As I wrote a guide to install OctoPrint under Fedora (which you can find here), I'll try to help @Charlie_Powell make his script compatible with Fedora and other RHEL-compatible systems.

Please take into account the difference between OctoPrint (the actual software written in Python) and OctoPi (a custom Raspberry Pi OS distribution shipped with OctoPrint). OctoPi 0.16 is a rather old version (a few years old IIRC) with an old version of Python 3. But you can upgrade OctoPrint without updating the underlying OS (in this case OctoPi).

As stated before, updating OctoPrint will not update the underlying OS (i.e. Raspberry Pi OS), which can be done on the command line by issuing the following commands: sudo apt-get update followed by sudo apt-get upgrade. Had you run those commands, the OS would have told you that a new version was available and that you should upgrade it, the easiest way would have been the one you followed, backing up the OctoPrint configuration and flashin the new version of OctoPi on the Pi's SD card.

@SwHawk

As stated before, updating OctoPrint will not update the underlying OS (i.e. Raspberry Pi OS), which can be done on the command line by issuing the following commands: sudo apt-get update followed by sudo apt-get upgrade . Had you run those commands, the OS would have told you that a new version was available and that you should upgrade it, the easiest way would have been the one you followed, backing up the OctoPrint configuration and flashin the new version of OctoPi on the Pi's SD card.

As a general note - I understand 100% that OctoPrint isn't responsible for necessary changes to the software environment, including the OS and Python. My complaints and "blues" are mainly about Raspberry Pi OS and the Linux-specific Python distros. (So I suppose that this thread of conversation doesn't belong in this forum, and I'll probably allow it to peter out after this response.)

Note that unlike Linux:

(1) Both Windows and macOS can perform major OS updates in place, i.e., without requiring a complete drive reformat; and

(2) Both Windows and macOS have Python distributions with precompiled binaries, so upgrades over even several major versions require a trivial uninstall and reinstall. No complete rebuild required. No manual package management of underlying dependencies required. And, certainly, no OS-level re-image required.

I love Linux and the entire Raspberry Pi platform, but its technical debt, compared to the state of the art, remains a persistent usability obstacle.

1 Like

Actually some Linux Distributions (Fedora among them) have offered that possibility since a few years ago (for nearly 5 years IIRC regarding Fedora). Debian doesn't offer such a streamlined path, but the package manager's configuration can be modified to be able to upgrade from one version to another (9/Jessie to 10/Buster)...

Actually most major distributions' package are pre-compiled binaries, There are only a few distribution where software are compiled on the target computer. The thing is some of the OS utilities rely on Python scripts for their administration, and are developped for a specific Python version, usually the one shipped with the version of the OS. Jumping to another version may render those scripts useless...

I'm not saying you're wrong, I'm just providing pointers as to why the things are the way they are... I totally agree with the fact that those point hinder Linux usability, but you also have to factor that each Linux distribution doesn't necessarily have the same manpower than Apple or Windows...

Apologies for the confusion around what Linux distros the script is compatible with, I'll try and make the guide clearer here. Definitely a case of I'm catering for what I know and the most popular solutions. Something like close to 90% of OctoPrint installs are through OctoPi, so Debian compatibility for the script/instructions probably covers a significant portion of the rest.

To clarify some things, and what I'll do:

  • The script is compatible with debian-based distros. I test it on Raspberry Pi OS/OctoPi, and Ubuntu as it's what I have easy access to, so I can guarantee compatibility there.
  • The instructions need to be clearer to note that the script will not work for everyone if you are not running a supported distro, which is very few people.

The argument about Linux vs Windows vs MacOS is not really necessary... They all have their strengths and weaknesses :wink:. I upgraded to Windows 11 and that was painless, but I will agree upgrading Debian versions is way way more painful. Anyway...

3 Likes

Most linux distros are upgradable in place. There are certain ones that are not, and octopi and raspbian are among those. I use Ubuntu on my Pi and just did an upgrade from 20.10 to 21.04 then from 21.04 to 21.10 without ever doing anything more than "sudo apt update && sudo apt upgrade" before and after each version upgrade. I did this coincidental to the octoprint upgrade to 0.17 as well. The only thing I have left to do is make a new image of the SD card so if something goes south I can recover quickly.

I chose to follow the instructions for the manual upgrade and that worked seamlessly as well.