英文:
How to replicate a conda environment?
问题
我已经成功在一台使用Anaconda和conda环境的Win10机器上安装了一些Python代码,并希望在另一台Win10机器上安装完全相同的环境。
这个页面指出,你可以在计算机1上保存一个包含环境信息的文件,然后在计算机2上调用它,使用以下步骤:
- 计算机1:
conda list --explicit > spec-file.txt
- 将文件从计算机1的工作目录复制到计算机2的工作目录
- 计算机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:
- computer 1:
conda list --explicit > spec-file.txt
- copy the file from the working directory of computer 1 to the working directory of computer 2
- 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
andconda 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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论