0

When I try to run a Python script from Sublime Text 3, I get a pop-up dialog box that simply says "EOFError()" and nothing else.

I'm using the SublimeREPL plugin, with some slight modifications to my C:\Users\Al\AppData\Roaming\Sublime Text 3\Packages\SublimeREPL\config\Python\Main.sublime-menu file (based off this video: https://www.youtube.com/watch?v=wM2LbXCkLDI ) so I can get an interactive shell opened in a separate tab that runs the program. The main change I made was adding the "-i" command line argument to the Python interpreter to run the interactive shell after the script finishes.

This has worked fine before. I'm not sure what changed in my configuration or Python or the SublimeREPL package to make it no longer work.

Here is my Main.sublime-menu file:

[
     {
        "id": "tools",
        "children":
        [{
            "caption": "SublimeREPL",
            "mnemonic": "R",
            "id": "SublimeREPL",
            "children":
            [
                {"caption": "Python",
                "id": "Python",

                 "children":[
                    {"command": "repl_open",
                     "caption": "Python",
                     "id": "repl_python",
                     "mnemonic": "P",
                     "args": {
                        "type": "subprocess",
                        "encoding": "utf8",
                        "cmd": ["python", "-i", "-u"],
                        "cwd": "$file_path",
                        "syntax": "Packages/Python/Python.tmLanguage",
                        "external_id": "python",
                        "extend_env": {"PYTHONIOENCODING": "utf-8"}
                        }
                    },
                    {"command": "python_virtualenv_repl",
                     "id": "python_virtualenv_repl",
                     "caption": "Python - virtualenv"},
                    {"command": "repl_open",
                     "caption": "Python - PDB current file",
                     "id": "repl_python_pdb",
                     "mnemonic": "D",
                     "args": {
                        "type": "subprocess",
                        "encoding": "utf8",
                        "cmd": ["python", "-i", "-u", "-m", "pdb", "$file_basename"],
                        "cwd": "$file_path",
                        "syntax": "Packages/Python/Python.tmLanguage",
                        "external_id": "python",
                        "extend_env": {"PYTHONIOENCODING": "utf-8"}
                        }
                    },
                    {"command": "repl_open",
                     "caption": "Python - RUN current file",
                     "id": "repl_python_run",
                     "mnemonic": "R",
                     "args": {
                        "type": "subprocess",
                        "encoding": "utf8",
                        "cmd": ["python", "-i", "-u", "$file_basename"],
                        "cwd": "$file_path",
                        "syntax": "Packages/Python/Python.tmLanguage",
                        "external_id": "python",
                        "extend_env": {"PYTHONIOENCODING": "utf-8"}
                        }
                    },
                    {"command": "repl_open",
                     "caption": "Python - IPython",
                     "id": "repl_python_ipython",
                     "mnemonic": "I",
                     "args": {
                        "type": "subprocess",
                        "encoding": "utf8",
                        "autocomplete_server": true,
                        "cmd": {
                            "osx": ["python", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"],
                            "linux": ["python", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"],
                            "windows": ["python", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"]
                        },
                        "cwd": "$file_path",
                        "syntax": "Packages/Python/Python.tmLanguage",
                        "external_id": "python",
                        "extend_env": {
                            "PYTHONIOENCODING": "utf-8",
                            "SUBLIMEREPL_EDITOR": "$editor"
                        }
                    }
                    }
                ]}
            ]
        }]
    }
]

UPDATE: When I look at the Sublime Text console, it shows this error after I tried to run a Python script:

Traceback (most recent call last):
  File "C:\Users\Al\AppData\Roaming\Sublime Text 3\Packages\SublimeREPL\sublimerepl.py", line 495, in open
    rv = ReplView(view, r, syntax, repl_restart_args)
  File "C:\Users\Al\AppData\Roaming\Sublime Text 3\Packages\SublimeREPL\sublimerepl.py", line 186, in __init__
    self._history = PersistentHistory(self.external_id)
  File "C:\Users\Al\AppData\Roaming\Sublime Text 3\Packages\SublimeREPL\sublimerepl.py", line 140, in __init__
    self._db.create("external_id", "command", "ts", mode="open")
  File "C:\Users\Al\AppData\Roaming\Sublime Text 3\Packages\SublimeREPL\repllibs\PyDbLite.py", line 193, in create
    return self.open()
  File "C:\Users\Al\AppData\Roaming\Sublime Text 3\Packages\SublimeREPL\repllibs\PyDbLite.py", line 246, in open
    self.fields = pickle.load(_in)
EOFError
error: EOFError()

I tried uninstalling and reinstalling SublimeRepl, then restarting Sublime Text, but I get the same error message.

I did some debugging, and found the _in was a file object of C:\Users\Al\AppData\Roaming\Sublime Text 3\Packages\User\.SublimeREPLHistory\python.db, an 819kb file. I tried deleting it (backing it up to another folder first) and restarting Sublime Text. This seemed to have worked! I guess somehow some null character was written to the history file? It works now. Thanks to MattDMo for pointing me to the Sublime Text console where I could find the error message.

Al Sweigart
  • 11,566
  • 10
  • 64
  • 92
  • Does this happen with any Python script or just a specific one? Also, are there any errors on the console (Ctrl-\`)? If so, can you add them to your question? – MattDMo May 26 '21 at 18:22
  • It happens for all Python scripts. I checked the console and followed up with the error message there. Thanks for pointing this out! I was able to fix the problem from there. – Al Sweigart May 30 '21 at 20:14

1 Answers1

0

I fixed this myself by deleting C:\Users\Al\AppData\Roaming\Sublime Text 3\Packages\User\.SublimeREPLHistory\python.db (though it'll be in a different folder for you depending on your username) and restarting Sublime Text.

I guess somehow some null character was written to the history file? It works now. Thanks to MattDMo for pointing me to the Sublime Text console where I could find the error message.

Al Sweigart
  • 11,566
  • 10
  • 64
  • 92