【问题标题】:Sublime Text 3 Python3 build not working?Sublime Text 3 Python3 构建不起作用?
【发布时间】:2020-08-09 12:05:48
【问题描述】:

我刚刚在我的 Linux Pop_!OS 计算机上安装了最新版本的 Sublime Text 3,但我无法运行 python 文件。

当我尝试使用带有CTRL-B 的python 构建文件时,它在日志中给我一个错误...

bash: python: command not found
[Finished in 0.0s with exit code 127]
[shell_cmd: python -u "/media/kevinapetrei/KEVIN USB/Files/Programming/Python Programs/Finished/HiLo Versions/HiLo-2.02/setup.py"]
[dir: /media/kevinapetrei/KEVIN USB/Files/Programming/Python Programs/Finished/HiLo Versions/HiLo-2.02]
[path: /app/utils/bin:/app/sublime_merge/bin:/app/bin:/usr/bin]

这很奇怪,因为我在终端上安装了一个包,它允许我使用命令python 来运行 python3。 (在终端中,我仍然可以使用命令 python 运行文件。

怎么了?我可以编辑它以使其以某种方式工作吗?

【问题讨论】:

    标签: python python-3.x sublimetext3


    【解决方案1】:

    如果内置方法不起作用,您可以在 Linux 上为 python3 创建一个新的build system

    首先,打开你的终端并写入

    $ which python3
    

    它会给你python3的位置

    /usr/bin/python3
    

    然后在崇高的文本中转到tools -> Build System -> New Build System并将下面的代码粘贴到该文件中,如果它位于不同的位置,则更改python的位置:

    {
     "cmd": ["/usr/bin/python3", "-u", "$file"],
     "file_regex": "^[ ]File \"(...?)\", line ([0-9]*)",
     "selector": "source.python"
    }
    

    现在使用anyname_you_want.sumblime-build 保存它并打开一个python 文件,然后选择tools -> Build System -> anyname_you_want 并运行你的python 文件。它应该可以工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-31
      • 1970-01-01
      • 2014-05-14
      相关资源
      最近更新 更多