How do I run python from Sublime text 3?

泪湿孤枕 提交于 2019-12-20 06:07:08

问题


I just got python and sublime 3. When I press control + b, I get this in the console:

'python' is not recognized as an internal or external command, operable program or batch file.

And it won't run my amazing code!

print"Hi"

I do have Python installed, and how do I change the PATH?


回答1:


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. Don't starting learning Python with 2, you'll pick up all sorts of bad habits. Learn with 3, then go back and find out the differences with 2 when you can understand them. I'm assuming you're on a 64-bit system, as everything is these days, so download Python 3 from here. 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". Finish the installation, restart Sublime, and it should pick up python.exe just fine.

BTW, in Python 3, print is a function, so your first code to run should be

print("Hi!")

Don't forget to save the file before building.

Oh yeah, avoid "Learn Python the Hard Way" like the plague. It sucks. Instead, read the official tutorial first, then pick something here and/or here.



来源:https://stackoverflow.com/questions/36659256/how-do-i-run-python-from-sublime-text-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!