TLDR
Use Conda Pack
install using conda or pip:
conda-forge:
conda install -c conda-forge conda-pack
PyPI:
pip install conda-pack
Then for:
Backing up:
# Pack environment my_env into my_env.tar.gz
$ conda pack -n my_env
# Pack environment my_env into out_name.tar.gz
$ conda pack -n my_env -o out_name.tar.gz
# Pack environment located at an explicit path into my_env.tar.gz
$ conda pack -p /explicit/path/to/my_env
Restoring:
And to restore it on the other machine(s):
# Unpack environment into directory `my_env`
$ mkdir -p my_env
$ tar -xzf my_env.tar.gz -C my_env
# Use Python without activating or fixing the prefixes. Most Python
# libraries will work fine, but things that require prefix cleanups
# will fail.
$ ./my_env/bin/python
# Activate the environment. This adds `my_env/bin` to your path
$ source my_env/bin/activate
# Run Python from in the environment
(my_env) $ python
# Cleanup prefixes from in the active environment.
# Note that this command can also be run without activating the environment
# as long as some version of Python is already installed on the machine.
(my_env) $ conda-unpack
a bit of an explanation :
If you plan on getting an exact copy of your current environment and then move it to another machine with the same platform and OS, without redownloading all packages again from Internet (good for offline machines/behind firewalls). All other previous methods require internet connection. so in case you dont have access to internet, then you can use conda pack
.
Conda Pack
Conda-pack is a command line tool that archives a conda environment,
which includes all the binaries of the packages installed in the
environment. This is useful when you want to reproduce an environment
with limited or no internet access. All the previous methods download
packages from their respective repositories to create an environment.
Keep in mind that conda-pack is both platform and operating system
specific and that the target computer must have the same platform and
OS as the source computer.
To install conda-pack, make sure you are in the root or base
environment so that it is available in sub-environments. Conda-pack is
available at conda-forge or PyPI.
for future updates check the ref