如何复制一个 conda 环境?

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

How to replicate a conda environment?

问题

我已经成功在一台使用Anaconda和conda环境的Win10机器上安装了一些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

尝试使用以下命令进行导出:

计算机1 - conda env export > spec-file.yml

计算机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.html
匿名

发表评论

匿名网友

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

确定