如何复制一个conda环境?

huangapple go评论93阅读模式
英文:

How to replicate a conda environment?

问题

我已成功在一台运行Win10的计算机上使用Anaconda和conda环境安装了一些Python代码,并希望在另一台运行Win10的计算机上安装完全相同的环境。

此页面 指出,你可以在计算机1上保存一个包含环境信息的文件,然后在计算机2上使用以下方法调用它:

  1. 计算机1:conda list --explicit > spec-file.txt
  2. 将文件从计算机1的工作目录复制到计算机2的工作目录
  3. 计算机2:conda create --name myenv --file spec-file.txt

第1步对我来说正常工作,但第3步出现了ResolvePackageNotFound错误,列出了基本上在文本文件中的所有包。

我是否漏掉了什么?
是否有一种方式可以半自动地从那个文本文件中安装包?

英文:

I have successfully installed some python code on a Win10 machine using Anaconda and conda environments and would like to install exactly the same environment on another computer, also Win10.

This page indicates that you can save a file that contains the environment info on computer 1, then recall it on computer 2, using:

  1. computer 1: conda list --explicit > spec-file.txt
  2. copy the file from the working directory of computer 1 to the working directory of computer 2
  3. computer 2: conda create --name myenv --file spec-file.txt

Step 1 works fine for me but step 3 fails with a ResolvePackageNotFound error, listing basically all the packages that are in the text file.

Am I missing something?
Is there a way to semi-automatically install the packages from that text file instead?

Edit: summary from the answers and comments (thank you!):
  • if conda install was used to install packages in computer 1, then what is written above is the best way to do an exact replication.
  • if pip install was used instead for packages installation (as was the case for me), the chosen solution below is the most appropriate one (conda env export and conda env create)

答案1

得分: 1

Computer 1 - conda env export > spec-file.yml

Computer 2 - conda env create -f spec-file.yml

英文:

try using export --

Computer 1 - conda env export > spec-file.yml

Computer 2 - conda env create -f spec-file.yml

huangapple
  • 本文由 发表于 2023年8月9日 11:34:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76864397-2.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定