简体   繁体   English

在 ubuntu 上的 Atom 中运行 python3 代码的问题

[英]problem with Run python3 code in Atom on ubuntu

script i am using this package on atom.脚本我在 atom 上使用这个包。

getting this error收到这个错误

[Command: python3 -u '/home/aditya/Documents/python/py4e book solved problems/not done py4e 5.10ex q1 loop.py']

after making change to.更改后。 [/home/aditya/.atom/packages/script/lib/grammars] i had changed python to python3 [/home/aditya/.atom/packages/script/lib/grammars]我把python改成了python3

exports.Python =
  'Selection Based':
    command: 'python3'
    args: (context) -> ['-u', '-c', context.getCode()]

  'File Based':
    command: 'python3'
    args: ({filepath}) -> ['-u', filepath]

EDIT: if you just want to run python3 through atom: Open the atom-python-run package settings (atom Settings >> packages >> find atom-python-run >> settings) 编辑:如果您只想通过atom运行python3:打开atom-python-run程序包设置(atom设置>>程序包>>查找atom-python-run >>设置)

In F5 command section, change the default to python3 {file} . F5命令部分中,将默认值更改为python3 {file} It should look something like this. 它看起来应该像这样。

EDIT: Make sure that F5 doesn't interfere with another command from another package. 编辑:确保F5不会干扰来自另一个程序包的另一个命令。 Or else you can use F6 as well. 否则您也可以使用F6 在此处输入图片说明

Restart, atom. 重新启动,原子。 You should be good to go! 你应该很好走!

If you aren't able to run python scripts through atom. 如果您无法通过atom运行python脚本。 Then here's the package you can install. 这是您可以安装的软件包。

atom-python-run 原子python运行

In short: 简而言之:

  1. You need python installed on your computer and you need to add it to your PATH 您需要在计算机上安装python,并将其添加到PATH

  2. Restart atom 重新启动原子

  3. To run your (.py) file, hit F5 or F6 要运行您的(.py)文件,请F6 F5F6

Hope this helps! 希望这可以帮助!

Try running "sudo ln -s /usr/bin/python3 /usr/bin/python".尝试运行“sudo ln -s /usr/bin/python3 /usr/bin/python”。

Anyway you can change the default to python3 {file} on settings atom python run from.无论如何,您可以在设置 atom python run 上将默认值更改为 python3 {file} 。

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

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