Upgrade your OctoPrint install to Python 3!

I think I found the problem. The guide for setting up OctoPrint doesn't mention telling the virtual environment where Python is installed. Only in migration page here does it tell you to do so. I hadn't so am surprised I had it working at all..

If you don't tell it which python to use it uses the system default. That's only slowly moving to python 3, hence the explicit declaration in the migration guide for plugin devs.

Well, whichever the issue, I don't recall there being a bin/Python directory. I made a total mes of something else so ended up re-creating the SD card image. Wasn't that a joy to go through.... (Sarcasm there) but when I get it all back up and running I'll try another go at migration and see what happens.

Performed, works perfect without any problems!

1 Like

Found out what the issue was btw; The version of virtualenvwrapper was funky. Devs had released version 5 then unreleased it, but it was still on one of the mirrors. Either specifying an earlier version or waiting until the mirror was fixed (it's been fixed) seems to have solved some of the issues I was having. Rest were issues with certain instructions missing some steps or assuming knowledge I didn't have.

It's now all installed and working.

Is this upgrade process compatible with 1.5.0rc3? I downloaded and ran the Python3 upgrade script after installing the latest rc and it indicated that it would install OctoPrint 1.4.2 as part of the process. That doesn't seem like something I'd want if I'm already running 1.5.0rc3.

Thanks.

I think you are correct. It will install the version of OctoPrint that is available on piwheels, which is the current stable 1.4.2 version. You would still be able to switch between stable and maintenance release after the process is complete, and that setting will actually be kept in the default base directory for all the config stuff, so as soon as you boot up after the upgrade, you will probably get prompted that there is an rc version available. You could still want it, as python 3 is more performant than 2 and the server seems much more responsive in my testing.

1 Like

Yep, @jneilliii is correct. It's set to install the stable release, so at the moment that would be 1.4.2. once it started however you would be prompted to update to 1.5.0rc3. I might be able to add a command line flag to install RC versions instead, coming soon...

1 Like

Thank you both. I'm now running 1.5.0rc3 with Python 3. The only fallout so far appears to be WebCamTab. I've tried both updating its __init__.py script and installing the patched version, but it's not displaying the camera's output. I've noted this in a comment regarding WebCamTab's Python 3 incompatibility but am thinking it may need to be a distinct issue.

2 Likes

Hi there,

I found a silly question, when I updated my OctoPrint Install to Python 3.
My OS is Windows, and it doesn't seem to support these two commands:

Is there any document that can guide me to upgrade my OctoPrint to Python 3 under Windows?

Many thanks!
Cheers!

Alternatively, you could install curl in windows I think.

https://curl.se/windows/

Thank you for your reply.

I feel like that the current problem is due to non-Linux OS instead of curl issues. The curl -L https://get.octoprint.org/py3/upgrade.py --output upgrade.py can successfully execute, but python3 upgrade.py cannot run.

So do you have any other suggestions on upgrading OctoPrint to Python 3?

Many thanks!

You'll have to re-do the installation unfortunately. All the data will remain, you just have to re-create the virtual environment using Python 3 as it is in the setup guide, then reinstall plugins. Back up and restore is not available in windows since it doesn't allow you to modify files that are in use.

The script is not compatible with OSes other than linux, it says that in the post on the OctoPrint blog but it seems the edits made there don't carry over to the forum post.

See also the section 'Manual Installs' under What do I do if my system is not supported?

Hi Charlie, I used your fantastic script and successfully moved to Py3. Thank you for making it painless. I have just one question - I am running Python 3.7.3 but 3.9.0 is available - should I upgrade and have you got any advice on the safest method to do so?

Thanks, as always, Matt

The latest available on Debian buster is 3.7. They don't add the new ones into the repos, so you can't just sudo apt install python39 like you can on ubuntu etc.

The next Debian release will come with Python 3.9. If you have this installed on a Pi, I don't recommend trying to build Python from source to update it - it will take a while. Someone might have built it (likely) but still, probably not worth the effort.

OctoPrint 2.0 will support Python 3.7 so you will not miss anything for a while.

1 Like

I think the script is having trouble parsing version numbers:

Detecting system info...
OctoPi version: 0.18.0
Unable to parse Python version string. Please report to me the line below that has caused problems....
[]
Virtual environment is already Python 3, are you sure you need an upgrade?

Any suggestions?

pi@octopi2021:~ $ ls /usr/bin/python*
/usr/bin/python     /usr/bin/python3           /usr/bin/python3.7m         /usr/bin/python3m
/usr/bin/python2    /usr/bin/python3.7         /usr/bin/python3.7m-config  /usr/bin/python3m-config
/usr/bin/python2.7  /usr/bin/python3.7-config  /usr/bin/python3-config
pi@octopi2021:~ $ python --version
Python 2.7.16
pi@octopi2021:~ $ python3 --version
Python 3.7.3

0.18 already ships with Python 3.

2 Likes

When I log into my newly installed Octopi via ssh and attempt to run the "curl" code you gave above, I get an error message:
Detecting system info...
OctoPi version: 1.0.0
Your OctoPi install does not support upgrading OctoPrint to Python 3 - Please upgrade your install.
Details: GitHub - cp2004/Octoprint-Upgrade-To-Py3: A script to move an existing OctoPrint install from Python 2 to Python 3
Looks like your OS is not linux, or the OctoPi version number is un-readable

I get this message even though I just installed Octopi on my Rpi today.

Any suggestions for how to get this to work?
Thank you.

OctoPi 1.0 is a nightly build - it does not need upgrading. Since 0.18 builds are Python 3 already.

Also, I don't recommend using the nightly build - use stable 0.18 from https://octoprint.org/download

Thanks Charlie. SO, I backed up a step and installed the 0.18 build. I am using an Ender 3 V2 and this gives me the same message about the temperature reporting anomaly. WHen I entered the suggested command via SSH:
pip install "https://github.com/SimplyPrint/OctoPrint-Creality2xTemperatureReportingFix/archive/master.zip"

I got an error message:
"-bash: pip: command not found"

How do I fix that so I load that temperature reporting anomaly which is apparently inherent in the Ender 3 V2 firmware?
Thanks!