如何制作可以在其他电脑上使用的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 导出环境文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何在 conda 环境中安装 Selenium?How to install Selenium in a conda environment?(如何在 conda 环境中安装 Selenium?)
使用 Anaconda installe 在 Windows 上获取 CUDA 和 CUDNNget the CUDA and CUDNN version on windows with Anaconda installe(使用 Anaconda installe 在 Windows 上获取 CUDA 和 CUDNN 版本)
如何下载适用于 python 3.6 的 AnacondaHow can I download Anaconda for python 3.6(如何下载适用于 python 3.6 的 Anaconda)
使用两个不同的 Python 发行版Using two different Python Distributions(使用两个不同的 Python 发行版)
除了 OSX 上现有的 pyenv 安装之外,如何安装 AnaHow can I install Anaconda aside an existing pyenv installation on OSX?(除了 OSX 上现有的 pyenv 安装之外,如何安装 Anaconda?)
在 Cygwin 中为 Anaconda 永久设置 Python 路径Permanently set Python path for Anaconda within Cygwin(在 Cygwin 中为 Anaconda 永久设置 Python 路径)