简体   繁体   English

WSL VSCode 调用 Windows Python 可执行

[英]WSL VSCode call Windows Python Executable

  • Context: Running python in VSCode on Windows上下文:在 Windows 上的 VSCode 中运行 python
  • Default Terminal is Bash (via WSL)默认终端是 Bash(通过 WSL)
  • Using WSL - Debian使用 WSL - Debian
  • Python 3 installed on Windows, not on WSL Python 3 安装在 Windows 上,不在 WSL 上

I want Bash to call my Windows Python Executable when I run my python files .我希望 Bash 在我运行 python 文件时调用我的 Windows Python 可执行文件 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).我只使用 WSL,所以我可以用 bash 替换 cmd/powershell。我不想在 WSL 上安装任何东西,我想使用 Windows 上的现有程序(在本例中为 Python)。

However when I try to run my Python file (Clicking 'play' button) I get the error:但是,当我尝试运行我的 Python 文件(单击“播放”按钮)时,出现错误:

-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我相信这可以通过将 C: 替换为 \mnt\c 来解决

How can I achieve this?我怎样才能做到这一点?

在此处输入图像描述

I had a same problem as yours.我和你有同样的问题。 I solved this by following steps.我通过以下步骤解决了这个问题。

  1. Open the VSCode打开VS代码
  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接下来你可以在“Reopen Folder in WSL”上方看到,在此处输入图像描述并单击
  4. Then you can run python with wsl and no more directory errors然后你可以用 wsl 运行 python 并且没有更多的目录错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM