简体   繁体   English

如何从Sublime text 3运行python?

[英]How do I run python from Sublime text 3?

I just got python and sublime 3. When I press control + b, I get this in the console: 我刚得到python和sublime3。当我按Control + b时,我在控制台中得到了这个:

'python' is not recognized as an internal or external command, operable program or batch file. 无法将“ python”识别为内部或外部命令,可操作程序或批处理文件。

And it won't run my amazing code! 而且它不会运行我的惊人代码!

print"Hi"

I do have Python installed, and how do I change the PATH? 我确实安装了Python,如何更改PATH?

If you installed Python 2, you'll need to just go ahead and install Python 3, as it's the present and future of the language. 如果您安装了Python 2,则只需继续安装Python 3,因为这是该语言的现在和将来。 Don't starting learning Python with 2, you'll pick up all sorts of bad habits. 不要从2开始学习Python,您会养成各种不良习惯。 Learn with 3, then go back and find out the differences with 2 when you can understand them. 与3一起学习,然后回过头来找出与2的区别,以便理解它们。 I'm assuming you're on a 64-bit system, as everything is these days, so download Python 3 from here . 我假设您使用的是64位系统,因为目前情况如此,因此请从此处下载Python 3。 If you're not, get this one . 如果不是的话,请获取这个 Run the installer, and pick the option (I forget exactly where it is) that says "Add Python to my PATH". 运行安装程序,然后选择“将Python添加到我的PATH”选项(我完全忘记了它的位置)。 Finish the installation, restart Sublime, and it should pick up python.exe just fine. 完成安装,重新启动Sublime,它应该可以正常使用python.exe

BTW, in Python 3, print is a function, so your first code to run should be 顺便说一句,在Python 3中, print是一个函数,因此您要运行的第一个代码应为

print("Hi!")

Don't forget to save the file before building. 在构建之前,请不要忘记保存文件。

Oh yeah, avoid "Learn Python the Hard Way" like the plague . 哦,是的,避免像瘟疫一样“艰难地学习Python”。 It sucks . 很烂 Instead, read the official tutorial first, then pick something here and/or here . 相反,请先阅读官方教程 ,然后在此处和/或此处选择内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM