Give OctoPrint a go on Python 3! Upgrade here

Upgrade OctoPrint to Python 3!

Since OctoPrint 1.4.0 (March 2020), we have had a core that supports both Python 2 and Python 3. At the time of writing, most plugins (66%) are Python 3 compatible as well. :clap: :clap: Well done to everyone involved, I've done a few of these myself, and it can be a good amount of work.

You may have seen an earlier version of this script, a couple of months ago. Now, it is entirely re-written to be far more stable and easier to use!

So how to upgrade? Just 2 simple steps...

  1. 1st, check that the plugins you depend on are compatible. All of the most popular ones are, it is now the plugins that are under less active development that are not. You can either install the plugin Python 3 Check by @jneilliii or from OctoPrint 1.4.1, this information is visible in the plugin manager.
  2. 2nd, Upgrade! Below is a script that will perform this upgrade for you. You can find out more details about it on the repository OctoPrint-Upgrade-To-Py3

    You will need to SSH into your machine, and run these commands: -

    curl -L https://get.octoprint.org/py3/upgrade.py --output upgrade.py
    python3 upgrade.py
    

    Follow the prompts, and you should be ready to run OctoPrint under Python 3!

Find something wrong? Please let me know either in the comments below or on the issue tracker


Couple of important things to note for you:
  • Only linux platforms are supported.
  • Only OctoPi 0.17 and newer are supported, 0.16 and earlier are missing required system dependencies. Please backup, [grab a new image from here](https://octoprint.org/download) and install that.
  • If you are on OctoPi but with custom OctoPrint installs, you may want to run using the flag --custom, to override the default config.

I'm running OctoPi 0.16 or earlier. What can I do?

Use OctoPrint's built in backup function, then re-image with OctoPi 0.17 or later - If you use the nightly 0.18 builds, then you can get straight into Python 3 without this script.

It is possible to upgrade from stretch to buster, but it requires quite a lot of effort and is not guaranteed to work flawlessly. I did try this, but it took a long time and decided it was not worth it, when there is another solution available.



If you find a plugin that you enjoy using regularly that is not yet Python 3 compatible, please do something about it!
There are several things you can do:
  • Open an issue on the plugin's repository, or look for one that already exists.
  • Help the author upgrade the plugin:
    If you think you've got something to offer, get in touch with the author! Many people work on plugins as a side project, and may not have the time to upgrade their plugins. Any offer of help will be appreciated.
4 Likes

Updated, to now include the redirect from https://get.octoprint.org/py3/upgrade.py. Makes the URL a bit easier to type!

Just a quick note: If anyone is using OctoPi 0.16, could they let me know this has worked for them, thanks!

Update: currently incompatible to OctoPi 0.16 as it comes with Python 3.5 installed, which is below the minimum requirement for OctoPrint. Hopefully should be getting this sorted soon.

I'm running the OctoPi 0.18 Beta (Pi4 8gb). Would this be "safe" to run, or because I'm on beta should I wait? Thx in advance...

It should be fine, I know a couple of people who have done it. However, depends when the beta was made, they now come with Py3 by default. But the script will check that and let you know, so go for it!

It worked great, thanks!

Updated the post as it is not possible to install OctoPrint Py3 on OctoPi 0.16 since Debian Stretch only has 3.5.3 in the repo, and OctoPrint requires >=3.6. As a result the script will check this, and does not install.

I'm running OctoPi 0.16 or earlier. What can I do?

Use OctoPrint's built in backup function, then re-image with OctoPi 0.17 or later - If you use the nightly 0.18 builds, then you can get straight into Python 3 without this script.

It is possible to upgrade from stretch to buster, but it requires quite a lot of effort and is not guaranteed to work flawlessly. I did try this, but it took a long time and decided it was not worth it, when there is another solution available.

does this mean it's finally time to roll out a new version of octopi? as it's pretty dated comming out of the box now that you have to upgrade python..

OctoPi comes with both Python 2 & 3 installed, as Raspberry Pi OS does I believe - that's why this upgrade is here. Takes OctoPrint installed on Py2, moves it to Py3.

OctoPi 0.18 does have Py3 as the default, but due to having to wait for the plugin repository to become Py3 compatible its not released yet. It is in nightly builds, but seeing as they are development nightlies, it doesn't make sense to roll it out to everyone.