The python path in your debug configuration is invalid visual studio code ошибка

Обновлено: 04.07.2024

Очень новичок в Python и VSCode (и stackoverflow). Я использую оба уже около 3 месяцев, просто отлично, до недавнего времени.

При попытке запустить любую базовую программу Python в отладчике появляется всплывающее окно The Python path in your debug configuration is invalid. Source: Python(Extension) , и отладчик не запускается. Я захожу в свой файл launch.json и, конечно же, у меня есть путь к тому месту, где установлен Python.

Возникновение с settings.json тоже ничего не помогает, потому что у меня есть настроенный путь к Python, но отладчик по-прежнему не запускается. Я не понимаю, что здесь делать. Раньше я никогда не заходил в свои файлы .json, и мне никогда не приходилось настраивать свой путь Python после первой установки VSCode.

Actual behaviour

now it doesnt recognize pypy path, since it says The python path in your debug configuration is invalid. It's a docker that i debug inside.

2 ответа

Оказалось, что мне пришлось понизить версию моего расширения Python с версии 2021.3 до 2021.2, теперь VSCode, наконец, может найти путь к Python.

Вы можете попробовать что-то подобное, но направив его туда, где ваша программа python установлена ​​в вашей системе

The text was updated successfully, but these errors were encountered:

dmorris0 commented Jan 3, 2021

I'm getting the same error in VSCode under WSL with Ubuntu 20.04. It used to work fine, but I installed Python 3.7, and now it can't find my interpreter. I even removed Python 3.7 and am getting this error.

dmorris0 commented Jan 3, 2021

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

I also encountered this, running the test from the file works fine, debugging the same test, vscode errors out with The Python path in your debug configuration is invalid , why isn't those paths the same as a default setting? Not sure I want to reinstall vscode atm. I can't find a way to set the pythonPath in the config. "pythonPath" shows up as not allowed .

How am I going to configure this?

@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.

image

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

scalavision commented Jan 6, 2021

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 😅

[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server ( python.languageServer: 'Microsoft' ), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]

Expected behaviour

I was able to run properly pypy up to a few weeks ago

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

VS Code version: 1.60.2
Extension version: v2021.9.1246542782
OS and version: Windows 10 Home and 20H2
Python version: 3.9.5150
Type of virtual environment used: N/A
Relevant/affected Python packages and their versions: N/A
Relevant/affected Python-related VS Code extensions and their versions: Pylance and Python; v2021.9.3and v2021.9.1246542782
Value of the python.languageServer setting: python.defaultInterpreterPath

Expected Behaviour:
Upon selecting the python interpreter from its specified location, It must run smoothly in the debugging as well as Standard Terminal.

Actual Behaviour:
Upon Selecting the python interpreter from its specified location, it keeps showing me “The python path in your debug configuration is invalid”

Solutions I have tried:

  1. Checking the environment variables
  2. Uninstalling and Reinstalling VS Code
  3. Uninstalling and Reinstalling Python
  4. Downgrading to an older version of python (the latest is 3.9.7)
  5. Using Ctrl+Shift+p

The text was updated successfully, but these errors were encountered:

@karthiknadig I updated the original comment. Is there anything else I should add?

karthiknadig commented Sep 24, 2021

@abioz-aiz Can you share your launch.json?

"version": "0.2.0",
"configurations": [

This is my launch.json

karthiknadig commented Sep 24, 2021

@abioz-aiz You don't have to set python there, it will always be set to selected interpreter automatically.

abioz-aiz commented Sep 26, 2021

Where? I didn't set any of the code there, except for the internalConsole .

karthiknadig commented Sep 27, 2021

When you see that error, it means that the python path being used some here is wrong, or the python itself is failing to launch. The logs should provide some clue on what is failing here.

abioz-aiz commented Oct 1, 2021

This is the output:
User belongs to experiment group 'pythonaacf'
User belongs to experiment group 'pythonJediLSP'
User belongs to experiment group 'pythonDiscoveryModuleWithoutWatcher'
User belongs to experiment group 'pythonTensorboardExperiment'
User belongs to experiment group 'PythonPyTorchProfiler'
User belongs to experiment group 'pythonDeprecatePythonPath'
User belongs to experiment group 'pythonSortEnvs'
User belongs to experiment group 'pythonRunFailedTestsButtonDisplayedcf'
User belongs to experiment group 'pythonRefreshTestsButtonDisplayed'
User belongs to experiment group 'pythonRememberDebugConfig'
Error 2021-10-01 15:46:41: readdir() failed for "C:\Users\jbaks\AppData\Local\Programs\Python\Python39\python.exe" (Error: ENOTDIR: not a directory, scandir 'C:\Users\jbaks\AppData\Local\Programs\Python\Python39\python.exe')
Error 2021-10-01 15:46:46: Invalid Python Path 'c:\Python39\python.exe'
Error 2021-10-01 15:46:55: readdir() failed for "C:\Users\jbaks\AppData\Local\Programs\Python\Python39\python.exe" (Error: ENOTDIR: not a directory, scandir 'C:\Users\jbaks\AppData\Local\Programs\Python\Python39\python.exe')
Starting Pylance language server.
Error 2021-10-01 15:46:57: readdir() failed for "C:\Users\jbaks\AppData\Local\Programs\Python\Python39\python.exe" (Error: ENOTDIR: not a directory, scandir 'C:\Users\jbaks\AppData\Local\Programs\Python\Python39\python.exe')
Error 2021-10-01 15:46:57: Diagnostic Code: InvalidPythonInterpreterDiagnostic, Message: No Python interpreter is selected. You need to select a Python interpreter to enable features such as IntelliSense, linting, and debugging.
Diagnostic Code: InvalidPythonInterpreterDiagnostic, Message: No Python interpreter is selected. You need to select a Python interpreter to enable features such as IntelliSense, linting, and debugging.
Error 2021-10-01 15:47:00: readdir() failed for "C:\Users\jbaks\AppData\Local\Programs\Python\Python39\python.exe" (Error: ENOTDIR: not a directory, scandir 'C:\Users\jbaks\AppData\Local\Programs\Python\Python39\python.exe')

conda --version
Error 2021-10-01 15:47:02: readdir() failed for "C:\Users\jbaks\AppData\Local\Programs\Python\Python39\python.exe" (Error: ENOTDIR: not a directory, scandir 'C:\Users\jbaks\AppData\Local\Programs\Python\Python39\python.exe')
Error 2021-10-01 15:47:44: Invalid Python Path 'C:\Python39\python.exe'

karthiknadig commented Oct 1, 2021

@abioz-aiz Some thing is wrong with the python installation on your machine and the settings seem weird. It looks like C:\Python39\python.exe python either does not exist or has no execute permissions. C:\Users\jbaks\AppData\Local\Programs\Python\Python39\python.exe has been assigned to something that should really be a directory.

abioz-aiz commented Oct 8, 2021

User Settings.json:
"editor.minimap.enabled": true,
"window.zoomLevel": -1,
"workbench.colorTheme": "Atom One Dark",
"atomKeymap.promptV3Features": true,
"editor.multiCursorModifier": "ctrlCmd",
"editor.formatOnPaste": true,
"workbench.editorAssociations": "*.ipynb": "jupyter-notebook"
>,
"python.defaultInterpreterPath": "C:\Python39\python.exe",
"python.pythonPath": "C:\Python39\python.exe",
"notebook.cellToolbarLocation": "default": "right",
"jupyter-notebook": "left"
>,
"security.workspace.trust.untrustedFiles": "open",
"[jsonc]": "editor.defaultFormatter": "vscode.json-language-features"
>,
"python.autoComplete.extraPaths": [

abioz-aiz commented Oct 8, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

Читайте также: