简体   繁体   English

我们如何在 Atom 编辑器中运行 Python 脚本?

[英]How do we run a Python script in Atom editor?

How do we run a Python script in Atom editor?我们如何在 Atom 编辑器中运行 Python 脚本? Please see screenshot below with errors: Below I was testing if i can run python in Atom editor.请参阅下面的屏幕截图,其中包含错误:下面我正在测试是否可以在 Atom 编辑器中运行 python。 I have also ran the ( c:\\Anaconda3\\Scripts\\activate base )command in Anaconda prompt我还在 Anaconda 提示符下运行了 ( c:\\Anaconda3\\Scripts\\activate base ) 命令

In your Atom built-in terminal, you are first typing in "python" without any file arguments, and such bringing you into the Python Interactive Prompt, include the name of your file (num.py).在您的 Atom 内置终端中,您首先输入没有任何文件参数的“python”,然后将您带入 Python 交互式提示,包括您的文件名 (num.py)。

The SyntaxError you're getting is because your trying to run "python num.py" as code instead of a CMD command.您得到的 SyntaxError 是因为您尝试将“python num.py”作为代码而不是 CMD 命令运行。

In addition to @HarryKearney answer, there are a number of packages that will easily run scripts.除了@HarryKearney 的回答之外,还有许多可以轻松运行脚本的软件包。 For example, run-in-terminal allows you to press F5 to open a terminal or command prompt window running the python script.例如, run-in-terminal允许您按 F5 打开运行 python 脚本的终端或命令提示符窗口。 Some other options to do similar things are: atom-python-run , atom-runner , script to run code directly in atom and several others you can find in the package repository .执行类似操作的其他一些选项是: atom-python-runatom-runner 、直接在 atom 中运行代码的脚本以及您可以在包存储库中找到的其他几个选项。 Choosing one of these and installing it will probably make it a lot easy if you will be running python scripts frequently.如果您经常运行 python 脚本,选择其中之一并安装它可能会变得容易很多。

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

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