Sublime Forum

[Errno 2] No such file or directory: 'python3'--following Python Crash Course 2nd ed

#1

I know there are related posts but I have studied them without success. I’m on a Mac running Mojave 10.14.6
I’ve installed python 3; at the terminal,
$python3
gives:
Python 3.9.4 (v3.9.4:1f2e3088f3, Apr 4 2021, 12:32:44)
and I can run python3 without problems.
Trying to configure sublime text as per “python crash course” 2nd edition, following the steps carefully multiple times, when I build my “hello_world.py” code I get:
[Errno 2] No such file or directory: ‘python3’
[cmd: [‘python3’, ‘-u’, ‘/Users/spencerri/Dropbox/python_work/hello_again.py’]]
[dir: /Users/spencerri/Dropbox/python_work]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
[Finished]
Note: my Python3.sublime-build file reads:
{
“cmd”: [“python3”, “-u”, “$file”],
}

I’m out of (very elementary) ideas and would greatly appreciate any insight! I am working around this by creating code in the TextEdit utility and changing the .txt to .py; this actually works fine but I’d like to use the additional functionality of sublime text.

0 Likes

#2

If you type where python3 in the terminal, does it exist in one of the locations that are on your PATH:

[path: /usr/bin:/bin:/usr/sbin:/sbin]
0 Likes

#3

Well, I have found the solution after going around the net a lot.
I only had to change the code in the file “Main.sublime-menu” found in the directory:
/Users/User/Library/Application Support/Sublime Text/Packages/SublimeREPL/config/Python/Main.sublime-menu
by this other code:

[
 {
    "id": "tools",
    "children":
    [{
        "caption": "SublimeREPL",
        "mnemonic": "r",
        "id": "SublimeREPL",
        "children":
        [
            {"caption": "Python",
            "id": "Python",

             "children":[
                {"command": "repl_open",
                 "caption": "Python",
                 "id": "repl_python",
                 "mnemonic": "p",
                 "args": {
                    "type": "subprocess",
                    "encoding": "utf8",
                    "cmd": ["python3", "-i", "-u"],
                    "cwd": "$file_path",
                    "syntax": "Packages/Python/Python.tmLanguage",
                    "external_id": "python",
                    "extend_env": {"PYTHONIOENCODING": "utf-8"}
                    }
                },
                {"command": "python_virtualenv_repl",
                 "id": "python_virtualenv_repl",
                 "caption": "Python - virtualenv"},
                {"command": "repl_open",
                 "caption": "Python - PDB current file",
                 "id": "repl_python_pdb",
                 "mnemonic": "d",
                 "args": {
                    "type": "subprocess",
                    "encoding": "utf8",
                    "cmd": ["python3", "-i", "-u", "-m", "pdb", "$file_basename"],
                    "cwd": "$file_path",
                    "syntax": "Packages/Python/Python.tmLanguage",
                    "external_id": "python",
                    "extend_env": {"PYTHONIOENCODING": "utf-8"}
                    }
                },
                {"command": "repl_open",
                 "caption": "Python - RUN current file",
                 "id": "repl_python_run",
                 "mnemonic": "d",
                 "args": {
                    "type": "subprocess",
                    "encoding": "utf8",
                    "cmd": ["python3", "-u", "$file_basename"],
                    "cwd": "$file_path",
                    "syntax": "Packages/Python/Python.tmLanguage",
                    "external_id": "python",
                    "extend_env": {"PYTHONIOENCODING": "utf-8"}
                    }
                },
                {"command": "repl_open",
                 "caption": "Python - IPython",
                 "id": "repl_python_ipython",
                 "mnemonic": "p",
                 "args": {
                    "type": "subprocess",
                    "encoding": "utf8",
                    "autocomplete_server": true,
                    "cmd": {
                        "osx": ["python", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"],
                        "linux": ["python3", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"],
                        "windows": ["python", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"]
                    },
                    "cwd": "$file_path",
                    "syntax": "Packages/Python/Python.tmLanguage",
                    "external_id": "python",
                    "extend_env": {
                        "PYTHONIOENCODING": "utf-8",
                        "SUBLIMEREPL_EDITOR": "$editor"
                    }
                }
                }
            ]}
        ]
    }]
}]

The answer I found is in this link: https://t.ly/KVQOq


Hi @OdatNurd
First, sorry for my bad english.

I’m new coding and I’m trying to execute Python in Sublime Text 3. I work with mac (Monterrey 12.6.6)
I have installed this version of python: /Applications/Python 3.11

I Think that I have the same problem than @RGS but I don’t Know how to fix it. See the image attached here down.

What can I do? I hope I explained myself well. :nerd_face:
Thanks for your time.

Nacho.

0 Likes