在Windows Subsystem for Linux(WSL)中创建一个Conda环境

编程语言 2026-07-09

我刚开始使用Windows Subsystem for Linux(WSL)。我有一个yml文件,用来创建名为proteomics_skani的环境,它是在WSL内部调用的,yml文件保存在我的Windows文件系统中:

name: proteomics_skani
dependencies:
  - python=3.10
  - pandas
  - numpy
  - requests
  - pip
  - scipy
  - spyder
  - bioconda::skani
  - conda-forge::networkx=3.1
  - pip=22.3.1
  - pip:
    - plotly==5.24.1
    - pytest==8.2.2

我需要在代码中使用Skani,它只在Linux上运行。我正在运行这个命令,在WSL中创建我的环境,这样我就可以在该环境中从WSL打开Spyder,并在Python中使用subprocess调用Skani程序。

然而,我遇到了一个错误:

(base) username@my-id:/mnt/c/Users/username$ conda create --file "mnt/c/Users/username/OneDrive - myUniversity/Desktop/proteomics_skani.yml"
2 channel Terms of Service accepted
Retrieving notices: done
ArgumentError: one of the arguments -n/--name -p/--prefix is required

有人能指出问题出在哪里吗?我猜把yml文件保存在WSL的目录/操作系统中会比较好,但我不知道应该把它放在哪里(只是 \\wsl.localhost\Ubuntu-24.04 的基础文件夹?)。

谢谢!

Tim

编辑

有人说更新的conda版本已经安装了,这点挺有意思的,因为它也显示我有问题的版本,但有更新的版本可用:

(base) username@my-id:/mnt/c/Users/username$ conda -V
conda 26.1.1


(base) username@my-id:/mnt/c/Users/username$ conda update --name base conda
2 channel Terms of Service accepted
Channels:
 - defaults
Platform: linux-64
Collecting package metadata (repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
    current version: 26.1.1
    latest version: 26.3.2

Please update conda by running

    $ conda update -n base -c defaults conda



# All requested packages already installed.



(base) username@my-id:/mnt/c/Users/username$ conda update -n base -c defaults conda
2 channel Terms of Service accepted
Channels:
 - defaults
Platform: linux-64
Collecting package metadata (repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
    current version: 26.1.1
    latest version: 26.3.2

Please update conda by running

    $ conda update -n base -c defaults conda



# All requested packages already installed.



(base) username@my-id:/mnt/c/Users/username$ conda -V
conda 26.1.1

解决方案

你可能需要检查你安装的版本有多旧

conda -V

我在版本 26.1.1 时也遇到了同样的错误,但更新到最新版本 26.3.1 后就开始工作了

conda install --name base conda=26.3.1

我甚至找到了 Conda 26.3.0/26.3.1的变更,并且有如下内容:

Notable Changes:

conda create --file and conda install --file accept environment.yaml 
as well as requirements.txt and explicit exports; 
with --name / --prefix omitted, the name or prefix is inferred from the file.
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。

相关文章