EOFError:EOF when reading a line


 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/

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM