Upgrade your OctoPrint install to Python 3!

Funny, I made a super half-hearted investigation to switch to Python 3 just last week. Saw it wasn't super easy and gave up. Then this post came out. Ran it on my most recent of three OctoPi 0.17 installs and it was super easy. No problems at all. Got the other two running right now but looks like I'll be able to switch everything to Python 3 with no problem at all. Thank you for making it so easy!

1 Like

I followed the instructions but get this error

pi@octopi:~ sudo curl -L https://get.octoprint.org/upgrade.py --output upgrade.py % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 154 100 154 0 0 1062 0 --:--:-- --:--:-- --:--:-- 1062 100 39304 100 39304 0 0 92917 0 --:--:-- --:--:-- --:--:-- 92917 pi@octopi:~ sudo python3 upgrade.py
File "upgrade.py", line 1

<!DOCTYPE html>
^

SyntaxError: invalid syntax

Can anyone help?

If you enter the command(s) you typed as Preformatted text (</> icon above), we might be able to see if there was a typo. Using PuTTY you can cut the command out of this thread and paste it in the SSH terminal window using right-click.

@uppermill - wrong URL, check it.

Should be https://get.octoprint.org/py3/upgrade.py

edit as @b-morgan says, just copy and paste it into an SSH window to get it exactly right

@cmh Thanks for the feedback :smile:

The script has been around in a sort of 'testing' state until now, I first wrote it back in June. There's a couple of forum posts etc. etc. but anyway great to hear it worked well for you.

Worked great! Thanks!!

1 Like

Thanks for the fast responses. I updated the URL and everything has now completed successfully.

1 Like

@Charlie_Powell Sweet, nice and easy, looks good. Pi4, 0.12-0.15 (Can't remember where this started) original install with about 10 plugins and standard updates/upgrades since. Took less than 5 minutes to run and looks to be working fine. Thanks for the sweet script!

1 Like

All went well with the base install, It initially screwed my GPX plugin. I couldn't install the plugin from the plugin manager so installed it manually. Re-created the gpx.ini file and away I went.

I'm running OctoPrint 1.4.2, OctoPi 0.18.0.

Thank you

Yeah, that bug of not being able to install should be fixed in the next release of OctoPrint.

If I were a newbie to Linux then I would have given up, So a message to anyone who is new and cannot follow logs and diagnose issues in Linux I would avoid the upgrade if you have tons of plugins. :slight_smile: But thank you to whoever created this script. I'm guessing @jneilliii?

Nope not me, @Charlie_Powell all the way. He's new on the scene and has quickly become a plugin author (WS281x LED Status) as well as a huge help in discord, here in the forum, and assisting Gina with issue/bug maintenance triage and fixing.

1 Like

Thanks @Charlie_Powell

1 Like

@Charlie_Powell Sorry, that is not correct. Klipper itself is written in Python. Look at this folder:

klippy is the core of Klipper's functionality. Klipper is still based on Python 2.7.There is even a branch of Klipper where work is being done on porting to Python 3, but it's stale. "Master" gets updates on a daily basis, the branch for Python 3 is three months old.

Octoklipper is simply a regular plugin for Octoprint, written by another guy.

It is not necessary for interoperability, but makes configuration of Klipper available through Octoprint which is pretty nice.

The plugin has a fork for Python 3 which seems to work pretty well.

Klipper itself seems quite stuck in 2.7. The maintainers are very active in developing functional improvements, but questions about Python 3 get canned answer. Since it's nothing I need to expose to the internet, that's sort of ok - as long as it stays compatible with my Octopi.

Ah ok, I read the wrong thing (maybe it was the printer firmware side? can't remember!), sorry.

I have done some more poking and it definitely creates its own virtual environment, looked through the install scripts - as good software does - so there should be no issue at all, since we are only touching OctoPrint's environment.

Klipper will still work, since all OctoPi distributions have both Python 2.7 and 3.x installed at a system level - that does not change in the script, the only thing that does is the virtual environment where OctoPrint (not klipper) is installed.

Hope that makes sense.

To add to that: while it is not possible to eg run OctoPrint with Python 3 and a plugin for OctoPrint with Python 2, it is possible to run OctoPrint with Python 3 and Klipper with Python 2 because they are different processes.

3 Likes

Isn't the plug-in for klipper required in order to use klipper?

From what I have heard, no, the plugin is not required. If you do intend to use the plugin with OctoPrint running on Python 3, you must use the Python 3 version of the plugin. However, Klipper itself can be running on Python 2.

Read (and follow) the instructions on upgrading more carefully. The upgrade script is not a plugin, so it should not be installed as a plugin. The upgrade script is something you would run in an SSH session (eg Putty), or using a keyboard and display on the Pi.

1 Like

Is there a python 3 version of the klipper plugin? I can't find one.