Upgrade your OctoPrint install to Python 3!

It seems to me the output of apt-get is parsed as utf-8 and this failed.

Do you have LANG with a non utf-8 encoding?

1 Like

Hey @jul!

Can you verify for me, which version of the script you have? It should be printed at the top.

The newer versions have a fix for your issues, please ensure you have script version V2.1.3 or later. (current is V2.1.8)

LANG=nl_BE
all the lines from upgrade.py are EN but :
sudo apt-get install python3-dev
Pakketlijsten worden ingelezen... Klaar
Boom van vereisten wordt opgebouwd
De statusinformatie wordt gelezen... Klaar
python3-dev is reeds de nieuwste versie (3.7.3-1).
0 opgewaardeerd, 0 nieuw ge▒nstalleerd, 0 te verwijderen en 19 niet opgewaardeerd.

is dutch : nl_BE
ge▒nstalleerd must be geïnstalleerd i with 2 dots is correct dutch

script current is V2.1.8
octoprint 1.4.2
oktopi 0.17.0

There should be a locale nl_BE.utf8

You could try LANG=nl_BE.utf8

When did you download the script?

I will look at it later, but this line 105:

Is different in the actual script, with a fix, for a while now:

output_line = process.stdout.readline().decode('utf-8', errors="replace")

Please try deleting the old one, then re-downloading it.

I ran the first line of the upgrade script and it seemed to go ok. Then when I ran "python3 upgrade.py", it asked if I wanted to proceed, I hit {enter} to continue,
-- it verified my OctoPi version 0.17.0,
-- it said Getting OctoPrint version ...
-- OctoPrint version 1.3.12

but then in the color RED is stated "Please upgrade to an OctoPrint version >= 1.4.0 for Python 3 compatibility"

I am confused, I thought the script was supposed to be doing that upgrade for me??? Now I am not sure what the next step is, can someone explain?

You are mixing up two things here. In order to switch to Python 3, two requirements need to be fulfilled. You need to be running OctoPrint 1.4.0, because earlier versions aren't yet even compatible to Python 3. And then you need to switch the Python virtual environment that OctoPrint lives in to Python 3. The script does the latter. OctoPrint itself can do the former.

Next steps for you: Update OctoPrint to 1.4.2, it will have asked you to do that anyhow. Then run the script again. It's impossible to switch to Python 3 while staying on OctoPrint 1.3.12.

1 Like

i changed the Lang in raspi-config but i get an error.
after running running upgrade.py with sucess i tried to start octoprint i get:
sudo service octoprint status
● octoprint.service - The snappy web interface for your 3D printer
Loaded: loaded (/etc/systemd/system/octoprint.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2020-10-01 18:33:35 CEST; 14s ago
Process: 2675 ExecStart=/home/pi/OctoPrint/venv/bin/octoprint (code=exited, status=203/EXEC)
Main PID: 2675 (code=exited, status=203/EXEC)

Oct 01 18:33:35 raspberrypi systemd[1]: Started The snappy web interface for your 3D printer.
Oct 01 18:33:35 raspberrypi systemd[2675]: octoprint.service: Failed to execute command: No such file or directory
Oct 01 18:33:35 raspberrypi systemd[2675]: octoprint.service: Failed at step EXEC spawning /home/pi/OctoPrint/venv/bin/oOct 01 18:33:35 raspberrypi systemd[1]: octoprint.service: Main process exited, code=exited, status=203/EXEC
Oct 01 18:33:35 raspberrypi systemd[1]: octoprint.service: Failed with result 'exit-code'.

there is no venv sub in the OctoPrint dir but there was one in the bak dir (version 2.7)
what do you suggest ?
jul

I would have set LANG=nl_BE.utf8 only in the shell before executing upgrade.py or only for this one command e.g.

LANG=nl_BE.utft8 upgrade.py

But at the moment this is irrelevant.

I'm nor very versed in the inner working of OctoPrint or Python but if systemd doesn't find the executable the installation is borked.

Oct 01 18:33:35 raspberrypi systemd[2675]: octoprint.service: Failed at step EXEC spawning /home/pi/OctoPrint/venv/bin/oOct 01 18:33:35 raspberrypi systemd[1]: octoprint.service: Main process exited, code=exited, status=203/EXEC

In the middle of this there is something missing, a copy&paste error:

/home/pi/OctoPrint/venv/bin/oOct 01 18:33:35

Before "Oct" there has to be a line break so at the end of "/home/pi/OctoPrint/venv/bin/o" is something missing.

If you can restore a working OctoPrint from the bak dir I would recommend it. Maybe a new try with the current version of upgrade.py as @Charlie_Powell suggested.

I've been on Python3 for a couple weeks now and it's awesome. But I have a small question:

My Python version at the bottom of the webui is 3.6.9. Can I / Should I upgrade the version of Python in the venv?

No, don't do that.

It will probably break the install on Linux. I tried updating the system Python version, but it did break every installed module. What would in theory work would be to install a new version alongside it. But I don't know how to do this with apt, the only way I know how to do it is building from source.

You won't gain anything either, so I would not worry. Far too much effort...

The old install is available in the .bak folder. It can just be renamed to the old one, to restore the old environment, and hopefully get it working again.

It seems you have a non standard install, so I can't easily help without a full report of how you have installed OctoPrint, what guides etc. were followed.

It might be easier for you to open a Get Help topic, filling out the full template. That will help you to get support more efficiently.

Sounds good. I'll just keep it where it is then.

1 Like

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: