Octoprint won't start (python issue/error?)

What is the problem?
My Problem is that Octoprint won't start. If i try to start it manually, even in safe mode. I get the follow error with the command Octoprint safemode:

pi@octopi:~ $ octoprint safemode
Traceback (most recent call last):
  File "/home/pi/oprint/bin/octoprint", line 8, in <module>
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/__init__.py", line 628, in main
    from octoprint.cli import octo
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/cli/__init__.py", line 141, in <module>
    from .user import user_commands
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/cli/user.py", line 13, in <module>
    from octoprint.access.groups import FilebasedGroupManager
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/access/groups.py", line 20, in <module>
    from octoprint.access.permissions import Permissions, OctoPrintPermission
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/access/permissions.py", line 9, in <module>
    from flask import g, abort
  File "/home/pi/oprint/local/lib/python2.7/site-packages/flask/__init__.py", line 19, in <module>
    from . import json
  File "/home/pi/oprint/local/lib/python2.7/site-packages/flask/json/__init__.py", line 25, in <module>
    import dataclasses
  File "/home/pi/oprint/local/lib/python2.7/site-packages/dataclasses.py", line 202
    class InitVar(metaclass=_InitVarMeta):
SyntaxError: invalid syntax

What did you already try to solve it?
Updated the system, pip and python as well

One other thing to mention: I've also installed another version of pip which makes it available globally, so i could use my RPi for Python Programming purposes. I reckon that there is some issue with different Pip or python versions.

Any suggestions on what i should do?
Any help is appreciated!


It looks like for some reason a Python 3 only dependency ended up in this Python 2 virtual environment there, possibly due to your upgrading of Python environment stuff. dataclasses shouldn't be there, and contains syntax that is incompatible to Python 2. Flask picks it up (though running under Python 2 it shouldn't) and then falls on its face trying to make sense of the Python 3 only syntax inside.

I suggest you recreate your virtual environment, because something seems to be seriously messed up with it.

mv ~/oprint ~/oprint.old
virtualenv ~/oprint
~/oprint/bin/pip install OctoPrint
sudo service octoprint restart

That solved my issue. Thank you so much for the quick reply! You really know your stuff :smile:
Keep up the good work!

Cheers :slight_smile:

1 Like