当我尝试使用SublimeREPL运行Python脚本时,Sublime Text 3显示EOFError()



当我尝试从Sublime Text 3运行Python脚本时,我会得到一个弹出对话框,上面只写着"EOFError((";什么都没有。

我正在使用SublimeREPL插件,对我的C:UsersAlAppDataRoamingSublime Text 3PackagesSublimeREPLconfigPythonMain.sublime-menu文件进行了一些轻微的修改(基于此视频:https://www.youtube.com/watch?v=wM2LbXCkLDI(,这样我就可以在运行程序的单独选项卡中打开一个交互式shell。我所做的主要改变是添加了"-i〃;Python解释器的命令行参数,以便在脚本完成后运行交互式shell。

这种方法以前运行良好。我不确定我的配置、Python或SublimeREPL包中发生了什么变化,使其不再工作。

这是我的Main.sublime-menu文件:

[
{
"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"
}
}
}
]}
]
}]
}
]

更新:当我查看Sublime Text控制台时,它在我尝试运行Python脚本后显示了这个错误:

Traceback (most recent call last):
File "C:UsersAlAppDataRoamingSublime Text 3PackagesSublimeREPLsublimerepl.py", line 495, in open
rv = ReplView(view, r, syntax, repl_restart_args)
File "C:UsersAlAppDataRoamingSublime Text 3PackagesSublimeREPLsublimerepl.py", line 186, in __init__
self._history = PersistentHistory(self.external_id)
File "C:UsersAlAppDataRoamingSublime Text 3PackagesSublimeREPLsublimerepl.py", line 140, in __init__
self._db.create("external_id", "command", "ts", mode="open")
File "C:UsersAlAppDataRoamingSublime Text 3PackagesSublimeREPLrepllibsPyDbLite.py", line 193, in create
return self.open()
File "C:UsersAlAppDataRoamingSublime Text 3PackagesSublimeREPLrepllibsPyDbLite.py", line 246, in open
self.fields = pickle.load(_in)
EOFError
error: EOFError()

我尝试卸载并重新安装Sublime Repl,然后重新启动Sublime Text,但我收到了相同的错误消息。

我做了一些调试,发现_inC:UsersAlAppDataRoamingSublime Text 3PackagesUser.SublimeREPLHistorypython.db的一个文件对象,一个819kb的文件。我试着删除它(先将它备份到另一个文件夹(,然后重新启动Sublime Text。这似乎奏效了!我想历史文件中不知怎么写了一些空字符?它现在起作用了。感谢MattDMo将我指向Sublime Text控制台,在那里我可以找到错误消息。

我自己通过删除C:UsersAlAppDataRoamingSublime Text 3PackagesUser.SublimeREPLHistorypython.db(尽管根据您的用户名,它会在不同的文件夹中(并重新启动Sublime Text来解决这个问题。

我想历史文件中不知怎么写了一些空字符?它现在起作用了。感谢MattDMo将我指向Sublime Text控制台,在那里我可以找到错误消息。

最新更新