从Sublime Text运行Python脚本时出现WinError

时间:2018-07-01 05:40:07

标签: python sublimetext

我有一个名为test.py的文件,内容如下:

print ("Welcome")

在Sumblime Text中运行此结果会在输出中出现以下错误:

[WinError 2] The system cannot find the file specified
[cmd: ['C:\\Users\\Mark\\AppData\\Local\\Programs\\Python\\Python35-32\\Python.exe', '-u', 'C:\\Users\\Mark Kaganovich\\Desktop\\test.py']]
[dir: C:\Users\Mark Kaganovich\Desktop]
[path: C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jre1.8.0_171\bin;C:\Users\Mark Kaganovich\AppData\Local\Programs\Python\Python37-32;C:\Users\Mark Kaganovich\AppData\Local\Programs\Python\Python37-32\python.exe;C:\Users\Mark Kaganovich\AppData\Local\Programs\Python\Python37-32\Scripts\;C:\Users\Mark Kaganovich\AppData\Local\Programs\Python\Python37-32\;C:\Users\Mark Kaganovich\AppData\Local\Microsoft\WindowsApps;]
[Finished]

1 个答案:

答案 0 :(得分:0)

您在environment variables中的python路径似乎与您运行的python不同。

您的python路径是:

  

C:\ Users \ Mark Kaganovich \ AppData \ Local \ Programs \ Python \ Python37-32

但是您的命令正在搜索:

  

C:\ Users \ Mark Kaganovich \ AppData \ Local \ Programs \ Python \ Python35-32

如果确定您拥有Python35-32,则只需将其添加到environment variables

以下是向python添加environment variables路径的说明:

How to add to the pythonpath in Windows?