Home > Net >  VS Code can't locate python executable and run programs through run button
VS Code can't locate python executable and run programs through run button

Time:06-28

I've been stuck trying to install Python on VS Code for the past few hours. I've searched and found multiple answers but I still get the same error whenever I try to run a program through the run button.

C:/Users/tomiw/AppData/Local/Programs/Python/Python310/python.exe c:/Users/tomiw/Desktop/Java/test.py

-bash: C:/Users/tomiw/AppData/Local/Programs/Python/Python310/python.exe: No such file or directory

When I check my files I can see the executable there, but for some reason VS Code does not recognize it.

CodePudding user response:

I had that issue for JS, the thing that fixed it for me was editing the systems properties, under the Environments variables.
After that I rebooted my computer and it worked.
If that dosent work try manually installing Python from their site.

CodePudding user response:

Did you install the python extension?

Please try uninstalling and reinstalling VS Code and python and python extensions. Follow this tutorial.

Other possible workarounds:

Set defaultInterpreterPath:

Add the following configuration to your settings.json file:

    "python.defaultInterpreterPath": "your_python_interpreter_path",

Custom interpreter path:

  1. Use Ctrl Shift P to open the command palette.
  2. search for Python:Select Interpreter.
  3. select the first item Enter interpreter path.
  4. Then paste the full path to your python.exe ( or go to explorer by selecting Find and select your python.exe ).
  • Related