Upgrade your OctoPrint install to Python 3!

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!

Unrelated to this issue, and OctoPrint has a plugin manager so you don't need to run any commands.


I ran the script and updated using an SSH login from my mac. But when I reboot the server It still says I am running python2 and receive this message.

Sorry for being a total noob. Where exactly does one enter the two script commands? I entered them in the terminal tab of octoprint, but got this error:
Send: curl -L https://get.octoprint.org/py3/upgrade.py --output upgrade.py
Recv: echo:Unknown command: "curl -L https://get.octoprint.org/py3/upgrade.py --output upgrade.py"

I'm running OctoPrint 1.7.2, Python 2.7.16, OctoPi 0.17.0

Step 1 :wink:

Where can I find the venv path the script is asking for?

This is where you installed OctoPrint. You would have set that when you set it up. It is often something like /home/pi/OctoPrint/venv, which is recommended in the RPi install path. But we can't really help if you don't know where you put it.

If you are using OctoPi then it should detect it automatically.

I am executing the Python upgrade and I encounter errors. After the upgrade completes and octoprint is restarted it exits. I don't see any errors/reason in the logs. When I manually execute 'octoprint serve', this command exits with Illegal Instruction. The last thing I see in the octoprint log is:

2022-01-02 10:28:27,864 - octoprint.plugin.core - INFO - Found 19 plugin(s) providing 19 mixin implementations, 43 hook handlers

Hardware: Raspberry Pi Model B Rev 2
OS: Linux raspberrypi 5.10.63+ #1496 Wed Dec 1 15:57:05 GMT 2021 armv6l GNU/Linux
Octoprint Version: 1.7.2
Python Version: 3.7.3

Looking for recommendations on how to proceed. Thanks!

That's interesting - illegal instruction is something we've sometimes seen on a corrupted install. It could be that something in the upgrade went wrong, in which case maybe try again - the backup of the old environment is stored as well.

Run the following switch back the environments (assuming this is an OctoPi install):

cd ~
mv oprint oprint-failed
mv oprint.bak oprint
sudo service octoprint

Remove pip's cache:

rm -rf ~/.cache/pip

Then try the update again.

Reattempted thpgrade per the steps provided. I saw this error in the upgrade log:

Reading installed plugins...
Exception in thread zeroconf-Reaper (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
  File "/home/pi/virtualenv/OctoPrint/local/lib/python2.7/site-packages/octoprint/vendor/zeroconf.py", line 1234, in run
  File "/home/pi/virtualenv/OctoPrint/local/lib/python2.7/site-packages/octoprint/vendor/zeroconf.py", line 1823, in wait
  File "/usr/lib/python2.7/threading.py", line 289, in __exit__
  File "/usr/lib/python2.7/threading.py", line 216, in __exit__
  File "/usr/lib/python2.7/threading.py", line 203, in release
<type 'exceptions.TypeError'>: 'NoneType' object is not callable

The upgrade script is continued but failed again in the same way. Anything else I should try?

For what it is worth, I attempted a manual install into a new Python3 virtual environment and saw the same behavior of the Illegal Instruction when starting up.

It seems like something in the Python environment has broken itself - I'm not sure how to fix it. It might be easier for you to take a backup and install OctoPi 0.18, which comes with Python 3 by default, as described in the main FAQ post: Upgrading your OctoPrint install to Python 3