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. 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...
- 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.
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.