_psposix.py file has EOL issue

Hi I recently found my octoprint was no longer working. In checking the log I found the below error:
Could not initialize environment detector: EOL while scanning string literal (_psposix.py, line 21)

I was able to open the file with nano, and it appears I am missing more than just a quotation mark:

__all__ = ['pid_exists', 'wait_pid', 'disk_usage', ement", 

Could someone who has their system working open their _psposix.py file and let me know what is supposed to come before ement"? I am assuming it is a partial word. I am hoping to avoid reimaging if I can fix the issue with a couple letters.

Please share the full logs for context.

2018-12-09 18:44:25,056 - octoprint.startup - INFO - ******************************************************************************
2018-12-09 18:44:25,065 - octoprint.startup - INFO - Starting OctoPrint 1.3.9
2018-12-09 18:44:25,067 - octoprint.startup - INFO - ******************************************************************************
2018-12-09 18:44:25,238 - octoprint.util.connectivity_checker - INFO - Connectivity changed from offline to online
2018-12-09 18:44:26,480 - octoprint.startup - INFO - Blacklist processing done, adding 1 blacklisted plugin versions: roomtemp (any)
2018-12-09 18:44:26,635 - octoprint.plugin.core - INFO - Loading plugins from /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins, /home/pi/.octoprint/plugins and installed plugin pack
ages...
2018-12-09 18:44:34,901 - octoprint.plugin.core - INFO - Found 11 plugin(s) providing 11 mixin implementations, 8 hook handlers
2018-12-09 18:44:35,145 - octoprint.startup - CRITICAL - Could not initialize environment detector: EOL while scanning string literal (_psposix.py, line 21)
2018-12-09 18:44:35,151 - octoprint.startup - CRITICAL - There was a fatal error starting up OctoPrint.

Weird, it doesn't give the full path. But it looks like that must be part of psutil. It wouldn't get randomly corrupted, so I'd be suspicious. Here's that line in the source, you could try patching it but I wouldn't be surprised if there are more problems.

Looking at what I have vs the source, I am thinking a reimage is in order. Very strange. Thank you for your help.

An EOL ( End of Line ) while scanning string literal error indicates that the Python interpreter expected a particular character or set of characters to have occurred in a specific line of code, but that those characters were not found before the end of the line . This results in Python stopping the program execution and throwing a syntax error . Reasons:

  • Missing quotes
  • Strings spanning multiple lines

Strings can't normally span multiple lines. If you don't want the string to appear on multiple lines but you want to initialize it on multiple lines (so you can read it more easily), you can "escape" the newline by putting a backslash before the newline. If you want it to appear on multiple lines, you can use triple quotes around the string. Python is particularly prone to this type of error, since Python ends statements with newlines/line breaks , whereas most other programming languages have a character such as a semicolon (:wink: , which means that other programming languages work more easily with multi-line statements out of the box.