EOFError:EOF when reading a line

简介: Sublime2编译Python程序EOFError:EOF when reading a line:  是因为Sublime2对于python中运行含有input或者raw_input的python代码时候会报错。

 Sublime2编译Python程序EOFError:EOF when reading a line:

 是因为Sublime2对于python中运行含有input或者raw_input的python代码时候会报错。

 就是Sublime中,运行python代码时,暂不支持输入参数。如果代码中包含用户输入的函数时(eg. raw_input())Command+b编译运行之后会提示以下错  误:

 解决方案, 安装SublimeREPL插件

 windows下:

 打开Sublime Text2编辑器,按 Ctrl+Shift+p,输入install,选择Package Control: Install Package,接着输入sublimeREPL,回车即可安装,安装完毕,  重启sublime即可。

 编译python文件的时候,可以选择【Tools】——【sublimeREPL】——【python】——【Python – RUN current file】即可运行程序提示用户输入。

 

倘若在编译python文件的时候,出现错误弹窗:"WindowsError(2, The system cannot find the file specified.)"
则是因为路径设置问题,解决方法如下:
Preferences -> Package Settings -> SublimeREPL -> Settings - User

输入以下配置信息:
{
"default_extend_env": {"PATH": "{PATH};C:\\Python27"}
}

  

Mac 下:

安装对应的包管理器。

快捷键:Ctrl+`,即是ctrl+‘1‘前面那个键)打开Sublime的console:

ctrl shortcut show sublime console

Ctrl+V,粘贴下面代码:

import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print('Please restart Sublime Text to finish installation')

  

到console中,然后按Enter键,稍等一下,此包管理器即安装完成:

 

然后重启sublime。

然后去

Preferences -> Package Control

选择Install Package

再选择sublimerepl:

很快就安装完成了。

编译python文件的时候,可以选择【Tools】——【sublimeREPL】——【python】——【Python – RUN current file】即可运行程序提示用户输入。

 

参考: http://blog.csdn.net/bravelee2009/article/details/9364737

         http://www.crifan.com/python_sublime_text_2_eoferror_eof_when_reading_a_line/

 

目录
相关文章
成功解决OSError: Unable to open file (truncated file: eof = 8388608, sblock->base_addr = 0, stored_eof =
成功解决OSError: Unable to open file (truncated file: eof = 8388608, sblock->base_addr = 0, stored_eof =
成功解决OSError: Unable to open file (truncated file: eof = 8388608, sblock->base_addr = 0, stored_eof =
|
6月前
|
Python
.repo/repo/main.py“, line 79 file=sys.stderr) SyntaxError: invalid syntax
.repo/repo/main.py“, line 79 file=sys.stderr) SyntaxError: invalid syntax
169 0
|
6月前
|
Unix Linux Shell
syntax error: unexpected end of file
syntax error: unexpected end of file
33 0
|
6月前
|
C语言 C++
关于DEV中collect2.exe [Error] ld returned 1 exit status的问题解决!!!
关于DEV中collect2.exe [Error] ld returned 1 exit status的问题解决!!!
|
Java
解决Command line is too long. Shorten command line for ServiceStarter or also for Application报错
解决Command line is too long. Shorten command line for ServiceStarter or also for Application报错
366 0
|
Linux iOS开发 MacOS
报错 sed: 1: extra characters at the end of d command
报错 sed: 1: extra characters at the end of d command
541 0
运行 ‘ApiApplication‘ 出错: Command line is too long. Shorten command line for ShopApiApplication or
运行 ‘ApiApplication‘ 出错: Command line is too long. Shorten command line for ShopApiApplication or
231 0
运行 ‘ApiApplication‘ 出错: Command line is too long. Shorten command line for ShopApiApplication or
Error running 'XXXApplication': Command line is too long. Shorten command line forXXX
Error running 'XXXApplication': Command line is too long. Shorten command line forXXX
158 0
Error running 'XXXApplication': Command line is too long. Shorten command line forXXX
Command line is too long. Shorten command line for AppWebStarter or...(已解决)
找到你项目中 .idea/workspace.xml文件 找到 < component name=“PropertiesComponent” > 在标签内部加上这句
166 0
Command line is too long. Shorten command line for AppWebStarter or...(已解决)