0
  • Context: Running python in VSCode on Windows
  • Default Terminal is Bash (via WSL)
  • Using WSL - Debian
  • Python 3 installed on Windows, not on WSL

I want Bash to call my Windows Python Executable when I run my python files. I am only using WSL so I can replace cmd/powershell with bash. I do not want to install anything on WSL, I want to use existing programs on Windows (in this case Python).

However when I try to run my Python file (Clicking 'play' button) I get the error:

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

I believe this can be solved by replacing C: with \mnt\c

How can I achieve this?

enter image description here

5
  • 1
    replace C: with /mnt/c and it might work. Perhaps in your vscode configuration. Commented Jan 4, 2022 at 7:58
  • @fredrik, which exact setting? Commented Jan 4, 2022 at 8:00
  • That I don't know - check your settings.json. code.visualstudio.com/docs/getstarted/settings Commented Jan 4, 2022 at 8:02
  • @fredrik thanks, though I'm starting to think what I'm attempting goes against the grain for WSL usage. Perhaps I'm better off uninstalling Windows Python and just using the WSL python instead lol Commented Jan 4, 2022 at 8:05
  • Probably. Though you can still use WSL python without uninstalling the one on windows. Commented Jan 4, 2022 at 8:09

1 Answer 1

1

I had a same problem as yours. I solved this by following steps.

  1. Open the VSCode
  2. On your left-down side, you can see the the icon that I pointed enter image description here (the name in here is "Open a Remote Window")
  3. Next you can see above the "Reopen Folder in WSL" enter image description here and clicked
  4. Then you can run python with wsl and no more directory errors
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.