quantCode
quantCode

Reputation: 565

How to package conda env into one single file?

There are anaconda, fully package conda env. and mini conda, with minium packagea.

Instead of exporting into yaml file or txt file, would like to export current env. into a bash executable sh file.

So, this file can be used to install env. for air gap environnments.

Upvotes: 1

Views: 8416

Answers (2)

Zhang Kin
Zhang Kin

Reputation: 89

Here is another solution for complex environments. There may be an error for conda-pack, especially envs with pip install and conda install different packages and have conflicts. Error Output for conda pack:

This is usually due to `pip` uninstalling or clobbering conda managed files,
resulting in an inconsistent environment. Please check your environment for
conda/pip conflicts using `conda list`, and fix the environment by ensuring
only one version of each package is installed (conda preferred).

So here is another tar conda environment I tested:

  1. check the env path:
conda env list
  1. cd to the env path and tar the env you want:
cd /home/$you_user/miniconda3/envs
tar -czvf ~/my_env_name_tar.tar.gz my_env_name
  1. extract to another path/computer/machine:
tar -xzvf my_env_name_tar.tar.gz -C /home/$you_user/miniforge3/envs

Note: for package environments in different OS this step might not working and officially conda recommend conda env export yaml file.

Upvotes: 0

David Smith
David Smith

Reputation: 191

I'd look into using conda-pack: https://conda.github.io/conda-pack/

It's used to ship a python environment in distributed environments like YARN, where a consistent Python environment is needed across many compute nodes.

You'll develop your environment in a space where internet access is possible and install the conda-pack, then pack it up as an archive eg: conda pack -n my_env -o out_name.tar.gz, and deploy it from the archive. Once you've unzipped the archive you need to source an activate script and it should be good to go. this will look something like: source <env_directory>/bin/activate

One thing it can't do is ship a windows environment to a Linux one and vice versa. see the docs linked for more details and caveats.

Upvotes: 4

Related Questions