使用 WSL Windows 10 中的 conda

Posted

技术标签:

【中文标题】使用 WSL Windows 10 中的 conda【英文标题】:Using conda from WSL Windows 10 【发布时间】:2019-03-22 19:28:45 【问题描述】:

我在我的 Windows 10 环境中安装了conda。当我尝试从我的 Ubuntu WSL 中使用 conda 时,它会抛出:

CommandNotFoundError:您的 shell 未正确配置为使用“conda activate”。 如果您的 shell 是 Bash 或 Bourne 变体,请使用

为当前用户启用 conda
$ echo ". C:\ProgramData\Miniconda3/etc/profile.d/conda.sh" >> ~/.bashrc

当我这样做时,我的 bash 在重新启动时会引发错误:

cygpath: command not found

-bash: /etc/profile.d/conda.sh: No such file or directory

我应该安装 Cygwin 以在 WSL 中使用 conda 吗?

【问题讨论】:

WSL 是 Linux 系统,为什么你不运行它自己的 Python/Conda 版本?我怀疑它能否很好地管理跨 Windows 到 Linux 的安装。 在 WSL 中安装和使用 Miniconda for Linux 以获得更好的结果。 我的主要用例是深度学习项目。 WSL 尚不支持 GPU。 github.com/Microsoft/WSL/issues/1788 @jgr0 你能让这个工作吗?我和你有同样的用例 我与 conda 开发人员确认,conda 的 windows 安装并不意味着在 WSL 中使用。您应该使用 conda linux 安装程序在 wsl 中安装 conda。所以很遗憾,我们不能共享库/环境。 【参考方案1】:

WSL 将安装在您计算机上的主要用户下。 但是您不能使用 WSL 中的 Conda(安装在 Windows 中)。

但是,您始终可以在 WSL 中安装 python 并使用 Windows 文件系统中的代码。 它将位于 /mnt 路径中。

【讨论】:

以上是关于使用 WSL Windows 10 中的 conda的主要内容,如果未能解决你的问题,请参考以下文章

Windows10 开机自启动 WSL1 中的ROS脚本

Windows10 开机自启动 WSL1 中的ROS脚本

在 Windows 10 上使用 Intellij IDEA 在 WSL 2 中运行和调试 Java

Windows 10专业版安装 WSL2 (Ubuntu 20.04)

Windows 10专业版安装 WSL2 (Ubuntu 20.04)

在Windows 10中启动WSL2 并安装Linux( Ubuntu 为例)并运行docker