Upgrade your OctoPrint install to Python 3!

I am running .17. I rcvd this error:

E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/dpkg/status
E: The package lists or status file could not be parsed or opened.
ERROR: failed to update package list
Please try manually

Cleaning up...
Fatal error: Exiting

Try updating the package list manually, with sudo apt-get update, that seems an issue with your OctoPi installation - nothing I can do about that.

Also check it is connected to the internet, then if you still need help solving the problem please open a separate topic in 'Get help'.

Definitely connected to the internet
pi@octopi:~ $ sudo apt-get update
[sudo] password for pi:
Get:1 http://raspbian.raspberrypi.org/raspbian buster InRelease [15.0 kB]
Hit:2 http://archive.raspberrypi.org/debian buster InRelease
Fetched 15.0 kB in 1s (13.8 kB/s)
Reading package lists... Error!
E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/dpkg/status
E: The package lists or status file could not be parsed or opened.

Thanks for the upgrade script.
I found that I had 3 plugins that used python V2, so deleted them first.
The upgrade script worked flawlessly :slight_smile:

I now just have to wait for the plugin owners to upgrade their pplugins to V3

cheers
ian

1 Like

I wish these 4 plugins would be upgraded to python 3

  • LayerDisplay (0.4.3) from Matt Thompson
  • OctoKlipper (0.2.5) from Martin Muehlhaeuser
  • Terminal Commands (0.1.6) from ieatacid
  • Webcam Tab (0.1.2) from Sven Lohrmann
    most importantly the Octoklipper plugin.

EDIT: Whoahh, I just realised that after removing the Octoklipper 0.2.5 plugin I could install the 0.3.1 version from Alice Weigt, which is python 3 compatible!!!
Hope that helps anyone
EDIT 2: Success: OctoPrint 1.4.2 Python 3.7.3 OctoPi 0.17.0 (deactivated the three plugins before upgrading with the script).
THANKS

1 Like

Yeah, the Klipper plugin it was adopted officially yesterday. Go and let the plugin authors know that you want Python 3 compatibility, for the others, at some point OctoPrint will drop Py2 support so they need to be made compatible.

On every plugin there is at least one "python 3 upgrade" issue.

my Terminal Commands Extended plugin is Py3 compatible...

1 Like

***Bed Visualizer is gone ***

The Python upgrade worked fine, printing seems to work ( just testing :slight_smile: )

Only I miss the Bed Visualizer, even after installing the plugin again, it does not appear

There should have been a link when installing that plugin that extra action is required. And @jneilliii posted that link in the comments, previously.

1 Like

that worked perfect !!

Many thx

1 Like
21:47 root@pine64 /opt/octoprint# python3 upgrade.py 
This script will only run on python 3.6+
Run using 'python3 upgrade.py'
21:49 root@pine64 /opt/octoprint# python3 --version
Python 3.5.3

@SR-G What do you want help with? Your python 3 version is too old.

Yeah. This should/could have been noted somewhere.

And now (i remember why i hate the python ecosystem - everything related to maintenance of application made with python is just a time sink) ...

Path: /opt/octoprint/venv
Path valid
Config directory: /home/octoprint/.octoprint
Config directory valid

To do the install, we need the service stop and start commands. (Leave blank if you don't have a service set up)
Stop command: systemctl stop octoprint
Start command: systemctl start octoprint
Getting OctoPrint version...
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 163, in _run_module_as_main
    mod_name, _Error)
  File "/usr/lib/python2.7/runpy.py", line 111, in _get_module_details
    __import__(mod_name)  # Do not catch exceptions initializing package
  File "/opt/octoprint/venv/local/lib/python2.7/site-packages/octoprint/__init__.py", line 7, in <module>
    import logging as log
  File "/usr/lib/python2.7/logging/__init__.py", line 26, in <module>
    import sys, os, time, cStringIO, traceback, warnings, weakref, collections
  File "/usr/lib/python2.7/weakref.py", line 14, in <module>
    from _weakref import (
ImportError: cannot import name _remove_dead_weakref
Failed to find OctoPrint install
If you are not on OctoPi, please check you entered the correct path to your virtual environment

And here i have no idea why my paths are not the proper ones.

Thanks a lot. GREAT! Will try it ASAP

That looks like an issue in your installation. Script's trying to run octoprint --version to find it, and that failed. Not sure what to suggest, does OctoPrint run properly normally?

It is right above the command in the blog post.

2 Likes

Will this affect my existing OctoDash setup if I update to Python 3 using your script?

The script will affect the OctoPrint that OctoDash communicates with, but not OctoDash itself. The script does not make any changes to the configuration of OctoPrint, just to the environment it is run in.

1 Like

I have no idea what the problem could be. "octoprint --version" command was running perfectly fine when launched by hand. Also by taking the exact command (including path) found in the logs (the one with "python -m octoprint --version"), that command was also working fine (giving proper octoprint version as a result).

My paths looked OK :

  • user "octoprint" --> config in "/home/octoprint/.octoprint"
  • custom installation in "/opt/octoprint/" (with a "venv" subfolder inside it) --> "/opt/octoprint" not accepted by the script, but /opt/octoprint/venv was accepted
    (i of course tryed several different paths, with no luck ...).

In the end :

  • my installation was working with python2 / octoprint 1.4.0
  • i had to upgrade the system (debian strech > buster) to have a python3 version with the minimal requirement (...)
  • at that point, my installation was not working anymore (i have no idea why)
  • i had to reinstall everything, and it has been quite time consuming :
    ** pip installation of octoprint still taken from the pip internal cache (so not working with python3 ...)
    ** issues with virtualenv not working (i had to pip upgrade again ... no idea why)
    ** had to reinstall plugins (as it seems they are not stored in .octoprint but in the base installation) (this is probably expected)
    ** tasmota plugin was not working on restart (i have no idea why) (plugin with a "!" at the beginning, in the log)
    ** other python environemnt errors i have forgotten ...

I spent 2-3 hours to have again a working setup !

So yeah, this is NOT an out-of-the-box process, and there are way too many pitfalls.

Octoprint is really a gread piece of software, with a strong community and very interesting features (i'm using it all the time for all my printings), but i really hope that at some point some peoples are going to rewrite everything from scratch in any other language than python (again : this is the worst ecosystem i've have worked with) (not spearking about the language itself, but really about the ecosystem : pip/easy_install garbage, python2/python3 migration, some things provided by packages at OS level / some things to install through packages manager, virtualenv, weird errors at runtime and not at compilation time, ...)