You must be using conda for this approach. You will need conda installed on the Source machine and the Target machine. The Source machine must have an internet connection, the Target does not. The OS in both environments must match; no going from macOS to Win10 for example.
1. (Source) Install conda-pack
in your base
python environment.
conda install -c conda-forge conda-pack
2. (Source) Create a new environment that you'll replicate.
Note: I've had some issues with python 3.8 envs, so try 3.7 in your new environment. See here.
conda create -n env-to-pack python=3.7
3. (Source) Install conda packages into your new environment.
Note: Prefer packages from conda as much as possible. Packages from pip are not guaranteed to work.
conda activate env-to-pack
conda install <whatever>
4. (Source) Switch back to base
environment and pack up your environment.
conda activate base
conda pack -n env-to-pack -o packed-env.tar.gz
5. (Source > Target) Copy the packed-env.tar.gz
from the source environment to the target environment.
6. (Target) Unpack the tar.gz
environment file to where you want the environment to go
Note: On Windows, you can do this with 7-zip. It'll take one step to decompress the gzip
and another step to unpack the tar
.
7. (Target) Unpack the environment and activate it
Note: Be sure you're using standard Command Prompt (cmd.exe
) on Windows, not Anaconda Prompt or PowerShell; those shells don't correctly add the right files to PATH.
cd unpacked-environment
.\Scripts\activate.bat
.\Scripts\conda-unpack.exe
8. (Target) Run Python in your unpacked-environment
The prompt should tell you that you're in the right environment after the last step, so you should see something like the following, which will allow you to then run python within this environment
(unpacked-env-name) C:\Some\Path\Where\Your\Environment\Is> python
This Gist has saved me today - thanks! Voting to integrate this in the conda-pack docs :)