A
A
a1_01-txt2021-02-07 20:27:46
linux
a1_01-txt, 2021-02-07 20:27:46

FileNotFoundError(2, "No such file or directory:'python'") when running python code?

Installed Linux Mint 20.1 XfCE on a laptop, updated drivers and programs through the package manager. I installed Sublime, activated it with a key from the network, tried to run the python3 code, an error came up: "bash: python: command not found", checked if there was at all (although I was sure that there was) python in the package manager (which is on Synaptic'e ), python exists and does not ask for updates. I decided to install Sublime REPL, but it didn't help either: "FileNotFoundError(2, "No such file or directory: 'python'"). On the command line or with other interactions with python3, the error is: "bash: python: command not found". Solved install separately Python 3.9.1., but didn't help.If

"Key Bindings" in Sublime:
[
{ "keys": ["ctrl+b"], "command": "
"id": "repl_python_run",
"mnemonic": "d",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["python", "-i" , "-u", "$file_basename"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING ":"utf-8"}
}
}
]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Karbivnichy, 2021-02-07
@a1_01-txt

Tools -> Build System -> New Build System
Next:

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

Save, for example, as Python3.sublime-buildin Tools -> Build System, select "Python3". That's it, now you can run Python scripts with CTRL+B.
PS: In Linux Mint 20.1, if I'm not mistaken, instead of "cmd": ["python3", "-i", "-u", "$file"], you can type "cmd": ["python", " -i", "-u", "$file"], in my opinion they removed python 2 from the system (I could be wrong).

F
Filipp42, 2021-02-07
@Filipp42

Try running python with python3.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question