Plugin Manager Bad Magic Number

What is the problem?
Octoprint Server won't start.

What did you already try to solve it?
No idea how to resolve this. Can I re-compile the plugin manager? Please can someone advise how I do this? Or do I need to re-install?

Logs (octoprint.log, serial.log or output on terminal tab at a minimum, browser error console if UI issue ... no logs, no support!)
2020-07-14 07:05:18,911 - octoprint.startup - CRITICAL - Could not initialize plugin manager: Bad magic number in /usr/lib/python2.7/distutils/command/init.pyc
2020-07-14 07:05:18,917 - octoprint.startup - CRITICAL - There was a fatal error starting up OctoPrint.

Additional information about your setup (OctoPrint version, OctoPi version, printer, firmware, browser, operating system, ... as much data as possible)
OctoPrint version: 1.4.0
OctoPi version: 0.15.0PE

caveat: I know nothing about the internals of OctoPrint
but: I do know about python
files ending in .pyc are compiled python files
they are derived from the source file ending in .py

so what I would do (YMMV) is

- check that /usr/lib/python2.7/distutils/command/__init.py__ exists
- rename /usr/lib/python2.7/distutils/command/__init__.pyc to /usr/lib/python2.7/distutils/command/__init__OLD.pyc
- try again

what SHOULD happen is that it recompiles to make xxx.pyc

you'll need to restart OctoPrint

Thanks for your prompt response. I tried this, but now the log says:

2020-07-14 07:59:05,901 - octoprint.startup - CRITICAL - Could not initialize plugin manager: No module named command.install
2020-07-14 07:59:05,908 - octoprint.startup - CRITICAL - There was a fatal error starting up OctoPrint.

Thanks in advance for anyone's assistance.

It looks like your filesystem has gotten corrupted. This can happen for example when the OS is not properly shut down before the power is disconnected.

Backup the .octoprint folder and burn a new image. Then restore the .octoprint folder and hope none of the files in the .octoprint folder were affected by the filesystem corruption.

Thanks, I did suspect this, but was hoping it wasn't the case - the joy's of the Pi!

Appreciate the note about what to backup - I'll give that a go and let you know how I get on.

As with any computer system with files you consider valuable, doing regular backups is always a good idea. OctoPrint has a backup command and you can download the resulting file somewhere safe. I have a USB SD card reader for creating new images for my RPi and I can plug the same device into the RPi itself and make a clone of the entire OS.

Also, the current octopi image is 0.17. You are running 0.15PE. What is the PE?

Obviously the re-install has fixed things, looks like all the config files were OK - thanks @mmcp42 and @fieldOfView for your suggestions.

@5ft24 - it's the image provided by Prusa on their website - any pointers on how to upgrade it?

There is no direct upgrade. You have to install 0.17 direct to the SD card. You can do a backup in octoprint, copy the backup file to a thumb drive, I stall octopi 0.17 and restore the backup you saved

OK thanks - thought that might be the case, appreciate the confirmation.