vscode-python: The Python path in your debug configuration is invalid.

Environment data

  • VS Code version: 1.45.1
  • Extension version (available under the Extensions sidebar):2020.5.80290
  • OS and version: win10
  • Python version (& distribution if applicable, e.g. Anaconda): python-3.8.3-embed-amd64
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): N/A

Expected behaviour

vscode can find python interpreter

Actual behaviour

vscode cann’t found python interpreter

Steps to reproduce:

  1. download python-3.8.3-embed-amd64.zip and Unzip it

  2. write sample python code and use vscode opened it:

print(123)
  1. create launch.json
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: cureent file",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "pythonPath": "e:/tools/re/python-3.8.3-embed-amd64/python.exe"
        },
    ]
}
  1. press f5 to debug it
  2. message fatal: image

sXc51RV7TZ

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 9
  • Comments: 15 (2 by maintainers)

Most upvoted comments

Follow The Microsoft guide to solve your problem.

https://code.visualstudio.com/docs/python/environments > “To select a specific environment, use the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P).”

I had wrong path to python interpreter in the user settings. When manually setting the path to the interpreter via the gui, to be used inside the dev container, it silently failed. I found it in the Python log output eventually. A popup for this error would have been very helpful 😅

@scalavision Can you share your debug configuration? Normally you don’t have to set the pythonPath in the debug configuration, unless you want to run your code using a different python.

you can also use “python” to set a custom python path (default uses the selected python path): image

Finally fixed the problem by uninstalling VSCode and reinstalling it. Now it can find the python interpreter.

Follow The Microsoft guide to solve your problem.

https://code.visualstudio.com/docs/python/environments > “To select a specific environment, use the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P).”

The best and the easiest solution. Thank you! 😃

I was able to fix this by adding python.pythonPath to my devcontainer.json:

{
  "name": "Python Data Analysis",
  "build": {
    "dockerfile": "Dockerfile",
    "args": {
    },
    "context": "..",
  },
  "runArgs": ["--hostname=docker-python"],
  "settings": {
    "python.pythonPath": "/usr/bin/python3"
  }
}

Running with the isolated script seems to cause the interpreterInfo script to fail in this scenario:

C:\Users\karth\Downloads\python-3.8.3>python.exe "c:\\GIT\\issues\\s p\\vscode-python\\pythonFiles\\pyvsc-run-isolated.py" "c:\\GIT\\issues\\s p\\vscode-python\\pythonFiles\\interpreterInfo.py"
Traceback (most recent call last):
  File "c:\\GIT\\issues\\s p\\vscode-python\\pythonFiles\\pyvsc-run-isolated.py", line 23, in <module>
    runpy.run_path(module, run_name="__main__")
  File "runpy.py", line 265, in run_path
  File "runpy.py", line 97, in _run_module_code
  File "runpy.py", line 87, in _run_code
  File "c:\\GIT\\issues\\s p\\vscode-python\\pythonFiles\\interpreterInfo.py", line 4, in <module>
    import json
ModuleNotFoundError: No module named 'json'

C:\Users\karth\Downloads\python-3.8.3>python.exe "c:\\GIT\\issues\\s p\\vscode-python\\pythonFiles\\interpreterInfo.py"
{"versionInfo": [3, 8, 3, "final"], "sysPrefix": "C:\\Users\\karth\\Downloads\\python-3.8.3", "version": "3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)]", "is64Bit": true}