Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install a conda environment when offline?

I would like to create a conda environment on a machine that has no network connection. What I've done so far is:

On a machine that is connected to the internet:

conda create -n python3 python=3.4 anaconda 

Conda archived all of the relevant packages into \Anaconda\pkgs. I put these into a separate folder and moved it to the machine with no network connection. The folder has the path PATHTO\Anaconda_py3\win-64

I tried

conda create -n python=3.4 anaconda --offline --channel PATHTO\Anaconda_py3 

This gives the error message

Fetching package metadata: Error: No packages found in current win-64 channels matching: anaconda  You can search for this package on Binstar with      binstar search -t conda anaconda 

What am I doing wrong? How do I tell conda to create an environment based on the packages in this directory?

like image 817
WalkingRandomly Avatar asked Jul 30 '15 16:07

WalkingRandomly


People also ask

Can I use conda without installing anaconda?

No, this is not possible: Currently supported install methods include the Anaconda installer and the miniconda installer. You will either need to install miniconda/anaconda, or use another package manager.


2 Answers

You could try cloning root which is the base env.

conda create -n yourenvname --clone root

like image 169
Arthur Alvim Avatar answered Oct 10 '22 04:10

Arthur Alvim


Short answer: copy the whole environment from another machine with the same OS.

Why

Dependency. A package depends on other packages. When you install a package online, the package manager conda analyzes the package dependencies and install all the required packages for you.

The dependency is especially heavy in anaconda. Cause anaconda is a meta package depends on another 160+ packages.

Meta packages,are packages do not contain actual softwares and simply depend on other packages to be installed.

It's totally absurd to download all these dependencies one by one and install them on the offline machine.

Detail Solution

  1. Get conda installed on another machine with same OS. Install the packages you need in an isolated virtual environment.

    # create a env named "myvenv", name it whatever you want # and install the package into this env conda create -n myvenv --copy anaconda 

    --copy is used to

    Install all packages using copies instead of hard- or soft-linking.

  2. Find where the environments are stored with

    conda info 

    The 1st value of key "envs directories" is the location. Go there and package the whole sub-folder named "myvenv" (the env name in previous step) into an archive.

  3. Copy the archive to your offline machine. Check "envs directories" from conda info. And extract the environment from the archive into the env directory on the offline machine.

  4. Done.

like image 31
Simba Avatar answered Oct 10 '22 04:10

Simba