Anaconda export Environment file(Anaconda 导出环境文件)
问题描述
如何制作可以在其他电脑上使用的anaconda环境文件?
How can I make anaconda environment file which could be use on other computers?
我使用 conda env export > 将我的 anaconda python 环境导出到 YMLenvironment.yml.导出的 environment.yml 包含这一行 prefix:/home/superdev/miniconda3/envs/juicyenv 映射到我的 anaconda 的位置,这在其他电脑上会有所不同.
I exported my anaconda python environment to YML using conda env export > environment.yml. The exported environment.yml contains this line prefix: /home/superdev/miniconda3/envs/juicyenv which maps to my anaconda's location which will be different on other's pcs.
推荐答案
我在 conda 规范中找不到任何允许您在没有 prefix: 的情况下导出环境文件的内容... 行.但是,正如 Alex 在评论中指出,conda 似乎没有从文件创建环境时关心前缀行.
I can't find anything in the conda specs which allow you to export an environment file without the prefix: ... line. However, as Alex pointed out in the comments, conda doesn't seem to care about the prefix line when creating an environment from file.
考虑到这一点,如果您希望其他用户不知道您的默认安装路径,您可以在写入 environment.yml之前使用 grep 删除前缀行代码>.
With that in mind, if you want the other user to have no knowledge of your default install path, you can remove the prefix line with grep before writing to environment.yml.
conda env export | grep -v "^prefix: " > environment.yml
无论哪种方式,其他用户都会运行:
Either way, the other user then runs:
conda env create -f environment.yml
并且该环境将安装在其默认的 conda 环境路径中.
and the environment will get installed in their default conda environment path.
如果你想为你的系统指定一个与默认安装路径不同的安装路径(与 environment.yml 中的 'prefix' 无关),只需使用 -p 标志,后跟所需的路径.
If you want to specify a different install path than the default for your system (not related to 'prefix' in the environment.yml), just use the -p flag followed by the required path.
conda env create -f environment.yml -p /home/user/anaconda3/envs/env_name
请注意,Conda 建议手动创建 environment.yml,如果您希望跨平台(Windows/Linux/Mac)共享您的环境,这一点尤其重要.在这种情况下,您可以省略 prefix 行.
Note that Conda recommends creating the environment.yml by hand, which is especially important if you are wanting to share your environment across platforms (Windows/Linux/Mac). In this case, you can just leave out the prefix line.
这篇关于Anaconda 导出环境文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Anaconda 导出环境文件
基础教程推荐
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- 求两个直方图的卷积 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 包装空间模型 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
