The VScode error "Error: spawn python ENOENT" typically occurs when Visual Studio Code is unable to locate the Python executable on the machine.
The full error from the logs:
originalException: [Error: spawn python ENOENT
at ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:478:16)
at process.processTicksAndRejections (node:internal/process/task_queues:83:21)] {
errno: -2,
code: 'ENOENT',
syscall: 'spawn python',
path: 'python',
spawnargs: [
and
interpreter: undefined,
id: '.python3./python./.-m#ipykernel_launcher'
Fix spawn python ENOENT
Here are a few steps you can try to resolve the issue:
Verify Python installation
Verify that Python is installed on your computer by opening a command prompt or terminal of VScode and typing:
python -V
If Python is installed, you should see the version number and a prompt:
Python 3.8.10
If you see something like: Command 'python' not found, did you mean
then you need to install Python.
Install Jupyter
If you try to run code from Jupyter notebook then you need to install Jupyter notebook by:
pip install jupyter
pip install jupyterlab
In some cases upgrade of package pyzmq
is needed
pip install --upgrade pyzmq
or reinstall:
pip uninstall pyzmq
pip install pyzmq
Create virtualenv
If there are multiple versions of Python installed on the computer, try specifying the path to the specific version you want to use in the settings.
In case of multiple Python versions we need to use virtual environments. To create new or select existing virtual environment in VScode do:
- Command Palette or CTRL + Shift + P
- Python: Select Interpreter
- select existing environment
- Python: Create Environment
- Select
venv
orconda
- select base Interpreter path
- Select
- Python: Select Interpreter
Reasons for Error: spawn python ENOENT
Error "spawn python ENOENT" can happen if:
- Python is not properly installed on your computer
- The path to the Python executable is not included in the system's PATH environment variable
- The path to the Python executable is not configured correctly in Visual Studio Code's settings.
More on Error: spawn python ENOENT
Additionally you can check
- Check that the path to the Python executable is included in the system's PATH environment variable. You can do this by:
Mac/Linux
echo $PATH
Windows
echo %PATH%
-
In VS Code go to settings and check the
python.pythonPath
setting. Make sure that it points to the correct location of your python executable -
Reinstall Python and configure the path to the executable correctly