Anaconda export Environment file

后端 未结 5 2052
后悔当初
后悔当初 2020-12-12 09:32

How can I make anaconda environment file which could be use on other computers?

I exported my anaconda python environment to YML using conda env export > en

5条回答
  •  温柔的废话
    2020-12-12 10:02

    I find exporting the packages in string format only is more portable than exporting the whole conda environment. As the previous answer already suggested:

    $ conda list -e > requirements.txt
    

    However, this requirements.txt contains build numbers which are not portable between operating systems, e.g. between Mac and Ubuntu. In conda env export we have the option --no-builds but not with conda list -e, so we can remove the build number by issuing the following command:

    $ sed -i -E "s/^(.*\=.*)(\=.*)/\1/" requirements.txt 
    

    And recreate the environment on another computer:

    conda create -n recreated_env --file requirements.txt 
    

提交回复
热议问题