Skip to content

Instantly share code, notes, and snippets.

@cpascual
Last active May 15, 2019 17:38
Show Gist options
  • Save cpascual/2dc988c08d174e60ae19d04af4c4f707 to your computer and use it in GitHub Desktop.
Save cpascual/2dc988c08d174e60ae19d04af4c4f707 to your computer and use it in GitHub Desktop.
Offline installation with conda

Scenario:

we want to create a conda environment using packages from arbitrary channels in a machine with no internet access (let's say that we want a machine with keras, sklearn and all taurus dependencies installed)

first create the environment on a connected machine

It is better to use a clean conda installation, so we will use a miniconda docker container

docker run -it --name tmpconda continuumio/miniconda3

NOW, FROM THE CONTAINER

conda config --add channels conda-forge
conda config --add channels tango-controls

conda create -n keras -y \
    pip \
    python=3 \
    pyqt=5 \
    itango \
    pytango \
    lxml \
    future \
    guidata \
    guiqwt \
    ipython \
    pillow \
    pint \
    ply \
    pyqtgraph \
    pythonqwt \
    numpy \
    scipy \
    keras \
    matplotlib \
    scikit-learn

# create a tarball with all cached packages (the pkgs dir can be found with `conda info`): 
cd /opt/conda/pkgs
tar -cf /pkgs.tar *.bz2

NOW, FROM OUTTSIDE THE DOCKER

# transfer the packages to the offline machine 
docker cp tmpconda:/pkgs.tar .
scp pkgs.tar <offlinemachine>:

NOW, FROM THE OFFLINE MACHINE

# create a directory for a local conda channel
mkdir -p $HOME/.conda/offline_channel/noarch
# put the the bz2 package files into the created dir
tar -C $HOME/.conda/offline_channel/noarch -xf pkgs.tar
# create an index for the channel
conda index $HOME/.conda/offline_channel/
# add the channel to the default conda ones (you can check that it worked with "conda info")
conda config --add channels file://$HOME/.conda/offline_channel/

# install or create env with --offline

conda create --offline -n keras \
    pip \
    python=3 \
    pyqt=5 \
    itango \
    pytango \
    lxml \
    future \
    guidata \
    guiqwt \
    ipython \
    pillow \
    pint \
    ply \
    pyqtgraph \
    pythonqwt \
    numpy \
    scipy \
    keras \
    matplotlib \
    scikit-learn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment