Upgrade your OctoPrint install to Python 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.


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, ...)

Hey I appreciate you're having issues, but can we stop the bashing of pretty much everything here please.

At least 2000 users have upgraded to Python 3 according to anonymous usage tracking, likely more (some estimates put total users 10x tracked installs), it is an out of the box process for most.

When I was developed this script it was incredibly extensively tested, on a wide range of systems. Nothing is without issues, but we try and keep them to a minimum.

I did actually try the route you made, upgrading Debian stretch to buster and it did break. Not just Python, but many things. The issue is all the packages built to work with stretch needed reinstalling, and especially with Python it is not easy to just 'update' it, in place of a previous install.

I did put a link of what to do if your system is not supported to upgrade, in the script but I guess it was never outputted to you since minimum requirements to even run were not met. It is mentioned on the repository here

I explicitly recommend a fresh installation, to avoid the issues you have mentioned, and I apologise if it hasn't worked well for you.

1 Like

Not going to happen under the official name or my lead. That strong community and very interesting features? All thanks to a vibrant ecosystem. That ecosystem? Python based. Rewrite from the ground up in another language? Suicide.

As @Charlie_Powell already pointed out, minimum requirements were pointed out in the post, precisely due to complications being observed during the extensive testing period over the past couple of months.

Installation at OS level has been not recommended for OctoPrint in ages, everything should really live in a venv. Stretch to Buster migration has been observed to break venv paths, that's sadly outside of my control (I'm not a Debian dev) and also one of the very reasons why the script has a minimum python version requirement. Long term the solution to any grievances is probably going to be a focus on container based deployment, but for that some work is still to be done so that the ecosystem won't be nuked in the process.

I get that this was a frustrating experience, but your posts come off as fairly ungrateful towards the tons of work that @Charlie_Powell put into this and for which I am really grateful and which made it pretty out-of-the-box for the majority of users out there who read and follow instructions, and it also feels like you are venting your general frustration with a programming language here at a handful of people that have absolutely no control over the direction and decision of said language.

Remember the human, don't vent at us here, and now let's get this away from language bashing and back on topic please.

1 Like

Sorry to be so dense but I just want to clarify. If I run the script and update OctoPrint will OctoDash run as usual with no issues or changes required?

Yes it will, OctoDash is not touched

Out of interest is there a reason why the update is not a part of the OctoPi installation? Can't the update just be pushed via apt?

OctoPrint is not installed as a system wide apt package, it is installed using pip inside your system installation of Python. There are many reasons that it is both impractical and even impossible to get OctoPrint installed via apt & update it from Python 2 to 3. It is less of an 'update' in this case, and more an automatic reinstall using your current installation, since it is also pretty much impossible to update a Python installation in-place, especially between major versions.

Apt updating is also a bit of a pain, since most people barely run apt upgrade on their OctoPi installs, this particular upgrade requires extra config, and you wouldn't believe how many issues are created by people doing system wide upgrades.

TLDR; Architectural limitations make it impossible to run via apt.

Cool thanks. I am one of the weirdo's that run apt upgrade on most things pretty often. :slight_smile:

I'll have to wait until most of the many plugins I have installed actually update to support the change. As of now, most of the major ones that shape my use of this claim to not. So patience is everything I guess :slight_smile:

You should push those plugin authors to upgrade, and if they are unresponsive file an abandonment ticket on the plugin repo.

That's going to be a lot of pushing. Exclude Region, Extra Distance Buttons, Filament Sensor Reloaded, Webcam Tab, Convert TF to SD, etc. I noticed some others have upgraded, so that's nice. Maybe I'll poke a few awesome peeps with a stick to see what their plans are.

BTW I just did the update, and I don't know if it's just placebo effect or not, but the web interface feels significantly faster. I know the original post said there was speed improvements, but I did not expect them to be quite so pronounced. I have not done a print yet, but so far so good.

1 Like

I'm not sure if I'm doing something wrong or not, so I'm going to ask here first instead of the GitHub. Let me know if I should post there instead.

I'm running Linux Mint 19, and running OP in a venv(/home/user/OctoPrint/venv). I run the script, and point it to that venv path, and I get this error:

Path: /home/hass/OctoPrint/venv
Virtual environment is already Python 3, are you sure you need an upgrade?
Please try again

I'm pretty sure I'm not on python 3, and the bottom of the Octoprint web page confirms that. It says 2.7.15.

What should I do now?