使用 WSL 和 VS Code 配置解释器

问题描述 投票:0回答:1

在 VS Code 中,我想将 WSL 中的 conda 环境配置为 Windows 中项目的解释器。这可以通过 PyCharm 实现,如此处所示。

使用 VS Code,我可以使用远程资源管理器扩展成功连接到 WSL,并选择位于 WSL 中的 conda 环境,如此处所示,但似乎我只能将其用于位于 WSL 中的项目,而不能用于位于窗户。

有没有办法在 VS Code 中将 WSL 中的 conda 环境用于 Windows 中的项目?

python visual-studio-code pycharm conda windows-subsystem-for-linux
1个回答
0
投票

我本地有Windows,还有wls2。 我为wsl安装了conda,并且运行了本地的项目。

首先,找到你要在wsl中打开的本地项目的路径。

例如

C:\Users\user_name\Desktop\try
。然后你可以打开一个linux终端并执行
wslpath "C:\Users\user_name\Desktop\try"
,将路径转换为linux路径。本地的文件位于/mnt文件夹中。
/mnt/c/Users/user_name/Desktop/try/

然后您只需执行

code /mnt/c/Users/user_name/Desktop/try/
即可将其打开。

但是 wsl 建议将项目存储在 /home 中以获得更好的性能。我建议将项目推送到 GitHub,然后使用 wsl vscode 克隆它。

我知道你不能在wsl中使用本地conda env,所以你必须使用wsl conda(linux conda)。

示例

© www.soinside.com 2019 - 2024. All rights reserved.