0

I've recently installed Sublime text on Ubuntu. When I try to run some python code, the following error is popped up:

bash: python: command not found
[Finished in 0.0s with exit code 127]
[shell_cmd: python -u "/home/user/Desktop/Python Project/test.py"]
[dir: /home/user/Desktop/Python Project]
[path: /home/user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin]

when I run python on the commandline, I get:


  command 'python3' from deb python3
  command 'python' from deb python-is-python3

When I run python3 on the commandline, I get:

Python 3.8.2 (default, Apr 27 2020, 15:53:34) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
11
  • Is python itself installed on your computer? Commented Jul 6, 2020 at 15:57
  • If you go to the command line, what does which python3 return? Commented Jul 6, 2020 at 15:58
  • These are build notes, not an error. Please include the error itself. Commented Jul 6, 2020 at 16:01
  • @JohnGordon Yes, I've installed python on my computer. Commented Jul 6, 2020 at 16:02
  • 1
    Is there a way you can configure Sublime Text to use python3 as the command instead of python? Commented Jul 6, 2020 at 19:29

1 Answer 1

3

The Sublime Text is configuring python instead of python3. You just need to add a new build system to the Sublime Text. To do that, Select Tools > Build System > New Build System... Now, a new file will open. Add the following code to this file:

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

Now, save the file as Python3.sublime-build. Now, change you Build System to Python3 and try to run you code again. Now, it should run successfully.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.