最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】Sublime Text 2中运行Python程序出错:The system cannot find the file specified

Python IDE crifan 10128浏览 0评论

【问题】

折腾:

【教程】把Sublime Text 2用作Python的IDE去实现Python的开发

的过程中,在Sublime Text 2中运行Python代码:

Tools->Build

sublime tools build

结果出错:

[Error 2] The system cannot find the file specified
[cmd:  [u’python’, u’-u’, u’D:\\tmp\\tmp_dev_root\\python\\tutorial_summary\\sublime_text_2_ide\\sublime_text_2_ide.py’]]
[dir:  D:\tmp\tmp_dev_root\python\tutorial_summary\sublime_text_2_ide]
[path: D:\tmp\dev_install_root\Python27_x64\Lib\site-packages\PyQt4;D:\tmp\dev_install_root\Perl64\site\bin;D:\tmp\dev_install_root\Perl64\bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;D:\tmp\WordPress\mysql\mysql-5.5.18\MySQL\MySQL Server 5.5\bin;D:\tmp\WordPress\DevRoot\MySQL\MySQL Server 5.5\bin;D:\tmp\WordPress\DevRoot\php-5.3.6-Win32-VC9-x64;D:\tmp\WordPress\DevRoot\php-5.3.6-Win32-VC9-x64\ext;D:\tmp\WordPress\DevRoot\Python27;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Java\jdk1.7.0_11\bin;/home/CLi/develop/docbook/tools/fop\lib;D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\docbook\tools\fop;D:\DevInstallRoot\FF\DD_IDE_1.1.2\TOK\BIN;D:\DevInstallRoot\FF\DD_IDE_1.2.0\TOK\BIN;D:\DevRoot\EmbeddedDevelop\trunk\Research\CLI\FF\FBK\develop\tools\develop-tools;D:\tmp\WordPress\DevRoot\Python27\Scripts;D:\tmp\dev_install_root\PostgreSQL\8.3\bin;D:\tmp\dev_install_root\ant\apache-ant-1.8.4\bin;C:\Program Files\nodejs\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\TortoiseSVN\bin;D:\DevRoot\IndustrialMobileAutomation\HandheldDataSetter\ANTLR\batchFile;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Users\CLi\AppData\Roaming\npm\]
[Finished]

截图:

sublime run python error

【解决过程】

1.很明显,是环境变量PATH中,没有包含对应的Python.exe的路径,所以找不到。

2.所以去给环境变量PATH中添加上此处的python安装路径:

D:\tmp\dev_install_root\Python27_x64

然后再重启Sublime,重新执行Python。

就找到Python了,可以运行此程序了,解决了此问题了。

 

【总结】

通过Sublime Text 2运行Python代码之前,确保PATH环境变量中,已经添加了Python的安装路径,这样才能找到对应的python.exe,然后才能正常运行你的python程序。

否则就会报错:The system cannot find the file specified


不过,又出现其他错误“EOFError: EOF when reading a line”,详见:

【已解决】Sublime中运行带input或raw_input的Python代码出错:EOFError: EOF when reading a line

转载请注明:在路上 » 【已解决】Sublime Text 2中运行Python程序出错:The system cannot find the file specified

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.341 seconds, using 22.06MB memory