Upgrade your OctoPrint install to Python 3!

Hey, a script that works the first time and didn't require me to Google something to get it to work, nice!
Ran on my custom setup of OctoPrint on Raspberry Pi OS, and everything worked as it should.

One point of feedback: It doesn't say what the default config directory is, like it does for the OctoPrint env and service commands, but it wasn't too difficult to figure out.

1 Like

So, decided to give it a try on my one box. I now continue to get "Not an OctoPrint backup, lacks metadata.json" when I go to restore the setup even though the ZIP file clearly contains that file. Fails whether I upload directly through an SFTP connection or through the OctoPrint interface. Create a backup of the raw system and that restores fine as long as I don't download it first and then try and restore it. Not sure what is failing but now I get to rebuild that Pi with my configuration. So to others, be careful if you chase this also.

Hi @Oli_vier

Could you open a new 'Get Help' topic with the information requested (logs etc.). Thanks!

Hi @FullReg

You would have to do it for each instance you run.

If you are on OctoPi, use the -c flag, so that you can enter the details of where your 2nd install is located.

More :point_right: https://github.com/cp2004/Octoprint-Upgrade-To-Py3#command-line-options

1 Like

Hey @Detlev_Rackow!
Your Klipper install will not be affected unless it is in the same virtual environment (Which it shouldn't....) . However, if you are using the Klipper Plugin, someone mentioned it was not Py3 compatible.

Hey guys can you help me with this error that I'm getting:

Detecting system info...
OctoPi version: 0.17.0
Getting OctoPrint version...
OctoPrint version: 1.4.2
Reading installed plugins...
No handlers could be found for logger "octoprint.plugin.core"
Traceback (most recent call last):
  File "upgrade.py", line 555, in <module>
    plugin_keys = read_plugins_from_backup(backup_location)
  File "upgrade.py", line 362, in read_plugins_from_backup
    with zipfile.ZipFile(backup_path, 'r') as zip_ref:
  File "/usr/lib/python3.7/zipfile.py", line 1204, in __init__
    self.fp = io.open(file, filemode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/.octoprint/data/backup/octoprint-backup-20200910-205803.zip'

Seems like something has gone wrong with the backup of that install.

Could you try running ~/oprint/bin/octoprint plugins backup:backup --exclude timelapses --exclude uploads, and see if an error is generated there.

@dmyers7 - you might want to open a new topic, in 'Get Help' as the backup really should work.

To reply to myself. I have Windows running in Parallels and decided to use MS Edge to pull a copy of a similar backup from another OctoPi instance, .... restored that to the refreshed box and it works..... Something in Safari and FireFox on a Mac I suppose. That will be a good enough workaround for me, but weird in general. I can start another thread to have that looked at.

1 Like

Hey folks, just mentioning this in case it helps other newbies. I didn't realize that the instance of Python that's used by OctoPrint is separate from the one that's used by Raspberry Pi OS.
You can see the OctoPrint Python version number by scrolling to the bottom of the OctoPrint web page.
Kudos to @Charlie_Powell for setting me straight on this.

1 Like

worked flawless besides the known bed leveler plugin, which also compiled single core for over 15min to tell me, it is not working properly afterwards. ;D

1 Like

Worked perfectly for me as well (after the long process of upgrading OctoPi and other things I had to reinstall.)

1 Like

There is a python 3 compatible fork and that person is taking over as maintainer to the official repo.

1 Like

You probably just need to run the command shown on the known issues page...

1 Like

I ran both of the commands as root.
It says that there were some error messages though...

Detecting system info...
OctoPi version: 0.17.0
Getting OctoPrint version...
OctoPrint version: 1.4.2
Reading installed plugins...
2020-09-10 18:06:56,358 - octolapse.init - INFO - Release mode detected.
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib/python2.7/logging/init.py", line 1676, in shutdown
h.close()
File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/logging/handlers.py", line 32, in close
self._executor.shutdown(wait=True)
AttributeError: 'OctolapseConsoleHandler' object has no attribute '_executor'
Error in sys.exitfunc:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib/python2.7/logging/init.py", line 1676, in shutdown
h.close()
File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/logging/handlers.py", line 32, in close
self._executor.shutdown(wait=True)
AttributeError: 'OctolapseConsoleHandler' object has no attribute '_executor'
Traceback (most recent call last):
File "upgrade.py", line 556, in
plugin_keys = read_plugins_from_backup(backup_location)
File "upgrade.py", line 363, in read_plugins_from_backup
with zipfile.ZipFile(backup_path, 'r') as zip_ref:
File "/usr/lib/python3.7/zipfile.py", line 1204, in init
self.fp = io.open(file, filemode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/.octoprint/data/backup/octoprint-backup-20200910-180656.zip'

0.17 has been out since November of 2019. Almost a year

2 Likes

thanks, i will try this evening :wink:

1 Like

I got this too - you need to run it as the pi user, not as root...

1 Like

I'm an active user of Octopi but no longer a techie. Would it not be possible to include this conversion in the next update?

Good morning,

i just upgraded my Octopi to Python 3 but then realized some addons I wanted to use aren't compatible.
Then I wanted to revert my installation with the downgrade script and now I'm left with no OctoPrint Version:

OctoPrint version : unknown
OctoPi version : 0.17.0

Can anyone help me with this one? I don't fancy to reinstall my whole raspberry....

When I try to rerun the upgrade script:

pi@octopi:~ $ python3 upgrade.py
OctoPrint Upgrade to Py 3 (v2.0.4)

Hello!
This script will move your existing OctoPrint configuration from Python 2 to Python 3
This script requires an internet connection and it will disrupt any ongoing print jobs.

It will install the latest version of OctoPrint (1.4.2) and all plugins.
No configuration or other files will be overwritten

Press [enter] to continue or ctrl-c to quit

Detecting system info...
OctoPi version: 0.17.0
Hmm, seems like you don't have an environment at /home/pi/oprint