The OctoPrint server is currently not running - Python corrupted anyway to restore?

What is the problem?

I shutdown my Octoprint server before a scheduled power cut on November 20. When power was restored I noted my HA saying unable to connect to Octoprint. I ignored it until today. When I navigated to the server I got the error message "The OctoPrint server is not running".

This is not a new setup. It has been running very reliably for years across multiple Pi and Octopi upgrades

What did you already try to solve it?

First thing I did was ssh into in and run apt update/upgrade. Reboot.

Then I tried to grep the process and it returned nothing.
Then I tried to restart the service, got no error on the console but after a brief wait and refresh on the browser, the same error came up.
Checked logs, last log is on the 20th no new logs added.
Restarted service again, and immediately ran the grep command it showed Octoprint was running.
A minute later nothing again.
So it crashes soon after starting.

Did the following

pi@octopi:~/oprint $ systemctl status octoprint.service
● octoprint.service - The snappy web interface for your 3D printer
   Loaded: loaded (/etc/systemd/system/octoprint.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Wed 2023-11-29 23:07:30 GMT; 35min ago
  Process: 9319 ExecStart=/home/pi/oprint/bin/octoprint serve --host=${HOST} --port=${PORT} (code=exited, status=0/SUCCESS)
 Main PID: 9319 (code=exited, status=0/SUCCESS)

Nov 29 23:07:25 octopi systemd[1]: Started The snappy web interface for your 3D printer.
Nov 29 23:07:29 octopi octoprint[9319]: 2023-11-29 23:07:29,875 - octoprint.startup - CRITICAL - Could not initialize settings manager: marshal data too short
Nov 29 23:07:29 octopi octoprint[9319]: 2023-11-29 23:07:29,876 - octoprint.startup - CRITICAL - There was a fatal error starting up OctoPrint.
Nov 29 23:07:29 octopi octoprint[9319]: Could not initialize settings manager: marshal data too short
Nov 29 23:07:29 octopi octoprint[9319]: There was a fatal error starting up OctoPrint.
Nov 29 23:07:30 octopi systemd[1]: octoprint.service: Succeeded

Looked up this

Tried to run activate didn't work... went into ~/oprint/bin and chmod +x ./activate same for pip. Tried to reinstall and got this

pi@octopi:~/oprint/bin $ sudo ./pip install --force-reinstall OctoPrint
Traceback (most recent call last):
  File "./pip", line 6, in <module>
    from pip._internal.cli.main import main
  File "/home/pi/oprint/lib/python3.7/site-packages/pip/_internal/cli/", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/home/pi/oprint/lib/python3.7/site-packages/pip/_internal/cli/", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/home/pi/oprint/lib/python3.7/site-packages/pip/_internal/cli/", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/home/pi/oprint/lib/python3.7/site-packages/pip/_internal/cli/", line 25, in <module>
    from pip._internal.cli.progress_bars import BAR_TYPES
  File "/home/pi/oprint/lib/python3.7/site-packages/pip/_internal/cli/", line 12, in <module>
    from pip._internal.utils.logging import get_indentation
  File "/home/pi/oprint/lib/python3.7/site-packages/pip/_internal/utils/", line 18, in <module>
    from pip._internal.utils.misc import ensure_dir
  File "/home/pi/oprint/lib/python3.7/site-packages/pip/_internal/utils/", line 21, in <module>
    from pip._vendor import pkg_resources
  File "/home/pi/oprint/lib/python3.7/site-packages/pip/_vendor/pkg_resources/", line 84, in <module>
  File "/home/pi/oprint/lib/python3.7/site-packages/pip/_vendor/packaging/", line 10, in <module>
    from pip._vendor.pyparsing import stringStart, stringEnd, originalTextFor, ParseException
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 724, in exec_module
  File "<frozen importlib._bootstrap_external>", line 857, in get_code
  File "<frozen importlib._bootstrap_external>", line 525, in _compile_bytecode
EOFError: marshal data too short

At this point I guess the setup is fubared (also I may not have shut this down cleanly, now I am not so sure if i shutdown Octoprint before the scheduled power cut). Is there anyway to salvage the settings/and the GCode files or maybe a backup, I honestly don't remember when I last took a backup and where I might find it. I know I have one somewhere because this is a newish Pi. What I care more about is the print history info :frowning:

Have you tried running in safe mode?

Cannot run it in safe mode...

Did running in safe mode solve the problem?


Systeminfo Bundle

Got this from the octoprint.log file

2023-11-19 14:51:17,711 - octoprint.plugin.core - INFO - 25 plugin(s) registered with the system:
|  ABL Expert Plugin (0.6) = /home/pi/oprint/lib/python3.7/site-packages/octoprint_ABL_Expert
|  Action Command Notification Support (bundled) = /home/pi/oprint/lib/python3.7/site-packages/octoprint/plugins/action_command_notification
|  Action Command Prompt Support (bundled) = /home/pi/oprint/lib/python3.7/site-packages/octoprint/plugins/action_command_prompt
|  Announcement Plugin (bundled) = /home/pi/oprint/lib/python3.7/site-packages/octoprint/plugins/announcements
|  Anonymous Usage Tracking (bundled) = /home/pi/oprint/lib/python3.7/site-packages/octoprint/plugins/tracking
|  Application Keys Plugin (bundled) = /home/pi/oprint/lib/python3.7/site-packages/octoprint/plugins/appkeys
|  Backup & Restore (bundled) = /home/pi/oprint/lib/python3.7/site-packages/octoprint/plugins/backup
|  Bed Visualizer (1.1.1) = /home/pi/oprint/lib/python3.7/site-packages/octoprint_bedlevelvisualizer
|  Classic Webcam (bundled) = /home/pi/oprint/lib/python3.7/site-packages/octoprint/plugins/classicwebcam
|  Core Wizard (bundled) = /home/pi/oprint/lib/python3.7/site-packages/octoprint/plugins/corewizard
|  Error Tracking (bundled) = /home/pi/oprint/lib/python3.7/site-packages/octoprint/plugins/errortracking
|  Event Manager (bundled) = /home/pi/oprint/lib/python3.7/site-packages/octoprint/plugins/eventmanager
|  File Check (2021.2.23) (bundled) = /home/pi/oprint/lib/python3.7/site-packages/octoprint_file_check
|  Firmware Check (2021.10.11) (bundled) = /home/pi/oprint/lib/python3.7/site-packages/octoprint_firmware_check
|  GCode Viewer (bundled) = /home/pi/oprint/lib/python3.7/site-packages/octoprint/plugins/gcodeviewer
|  Logging (bundled) = /home/pi/oprint/lib/python3.7/site-packages/octoprint/plugins/logging
|  Pi Support Plugin (2023.7.31) (bundled) = /home/pi/oprint/lib/python3.7/site-packages/octoprint_pi_support
|  Plugin Manager (bundled) = /home/pi/oprint/lib/python3.7/site-packages/octoprint/plugins/pluginmanager
|  Preheat Button (0.8.0) = /home/pi/oprint/lib/python3.7/site-packages/octoprint_preheat
|  PrettyGCode (1.2.4) = /home/pi/oprint/lib/python3.7/site-packages/octoprint_prettygcode
|  Print History Plugin (1.4.1) = /home/pi/oprint/lib/python3.7/site-packages/octoprint_printhistory
|  Software Update (bundled) = /home/pi/oprint/lib/python3.7/site-packages/octoprint/plugins/softwareupdate
|  Tasmota (1.1.3) = /home/pi/oprint/lib/python3.7/site-packages/octoprint_tasmota
|  TouchUI (0.3.18) = /home/pi/oprint/lib/python3.7/site-packages/octoprint_touchui
|  Virtual Printer (bundled) = /home/pi/oprint/lib/python3.7/site-packages/octoprint/plugins/virtual_printer
Prefix legend: ! = disabled, # = blacklisted, * = incompatible
2023-11-19 14:51:17,733 - octoprint.environment - INFO - Detected environment is Python 3.7.3 under Linux (linux). Details:
|  hardware:
|    cores: 4
|    freq: 1400.0
|    ram: 914006016
|  os:
|    bits: 32
|    id: linux
|    platform: linux
|  plugins:
|    pi_support:
|      model: Raspberry Pi 3 Model B Plus Rev 1.3
|      octopi_version: 0.18.0
|      throttle_check_enabled: true
|      throttle_check_functional: true
|      throttle_state: '0x0'
|  python:
|    pip: 20.3.3
|    version: 3.7.3
|    virtualenv: /home/pi/oprint


Additional information about your setup

OctoPrint version : 1.9.3
OctoPi version : 0.18.0


Please always share complete log files.

As you can't get OctoPrint to run at all because the underlying Python install is cooked, you can manually collect all your data from ~/.octoprint. In there you will find config.yaml for the settings, as well as data folders such as uploads and various things plugins have stored. You'll have to manually copy the data out since you can't use the inbuilt backup & restore.

1 Like

Thank you very much.

Is it safe to overwrite ~/.octoprint folder on a brand new setup? Or should I be more selective about it and copy things over one at a time?

I guess I'll do it and find out. Will report back :slight_smile:

To put an end to the saga, I finally sat down to redo the installation, and when browsing the SD card using filezilla I discovered a backup file. Copied it over and re-flashed Octopi.

One first load tried to recover the backup file and found out that was corrupted too :frowning:

But the zip file name gave me the pattern to look for in all my usual spots where I chuck backups and I found a 2 year old one. Managed to restore that. 2 years of history lost. That will teach me to be more diligent about backups. Time to find an auto backup plugin :slight_smile:

Thanks for you help everyone.

1 Like