Upgrade your OctoPrint install to Python 3!

it must be:
Oct 01 18:33:35 raspberrypi systemd[2675]: octoprint.service: Failed at step EXEC spawning /home/pi/OctoPrint/venv/bin/octoprint:
there is no Octprint/venv sub in the OctoPrint dir but there was one in the bak dir (version 2.7)

I think I have installing now but I think I lost my plugins. I will see after it is completed. THANKS!

delete the new dirs en rename the bak workt
and also the upgrade.py was a succes !
thanks folks
jul

1 Like

I think the biggest hurdle, for me at least and I doubt I'm the only one, is finding out how to upgrade on a manual install of OctoPrint from 2.7 Python to 3.7/3.8.

The Raspberry Pi I have is doing double duty, so I installed OctoPrint manually which automatically put it with Python 2.7. For brand new users who may be far more familiar with Windows it's a challenge to get it all up and running. I know I'm certainly hitting lots of spots where I need to look something up and finding the relevant page is.... disconcertingly hit and miss.

Everything seems to automatically assume you're running OctoPi.... For those like me who were looking for how to manually upgrade, didn't see the documentation menu item but did find the blog entry.... oh so many leads directed you to the blog entry.... the page you actually want is here.

This script does work for users with a manual install, so you should have been able to run it fine, just providing the paths to where you have it installed. The page you linked is targeted at plugin authors to update their plugins.

If there is something you want improved, please suggest specifically what it is, and the likely hood is that I or someone else will implement or improve it. Since things are open source, contributions are important

1 Like

OK, installing Octoprint I followed this guide.

I tried every combo I could think of for the venv path when I tried your script to upgrade that.

/home/pi/OctoPrint/venv
~/OctoPrint/venv

with and without the ` symbol. Everything reported as being invalid. I even tried without venv at the end. The script just refused everything.

it is looking for the python interpreter under venv/bin/python. So if you type out:

/home/pi/OctoPrint/venv/bin/python do you get python command prompt? If the answer is no, then you need to double check no typos were made when you installed it.

It does work for manual installs (I made a couple of updates last night, and I test it on both manual & OctoPi), when the path is typed correctly but if it can't follow the path, then there is nothing I can do. Apologies if it sounds like I'm trying to pin it back on you, but there are 4 different error messages for the path:

  1. Invalid path, please try again means it could not be found (does not exist)
  2. Venv is already Python 3, are you sure you need an upgrade? means python --version (in the venv) reports Python 3
  3. Please enter your path without a trailing slash
  4. Please enter a path! if you have not entered anything there

For reference, this is how I have entered my paths:

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?