Reputation: 204
I am trying to install packages with pip on my singularity container, but there seems to be no way of doing so without "borrowing" the packages from my machine. I have heard that I may need to use virtualenv's but even that seems to be a circuitous process. Does anyone know of a tried and true way of using packages from pip on their singularity container?
Upvotes: 1
Views: 14282
Reputation: 89
A good workaround is to install the required packages using conda.
BootStrap: docker
From: ubuntu:xenial
%environment
export PATH=/miniconda3/bin:$PATH
%runscript
exec vcontact "$@"
%post
apt-get update && apt-get install -y automake build-essential bzip2 wget git default-jre unzip
# Install miniconda
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b -f -p /miniconda3/
rm Miniconda3-latest-Linux-x86_64.sh
# pull the conda functions in . /miniconda3/etc/profile.d/conda.sh and make pip, etc. available while in %post
export PATH="/miniconda3/bin:$PATH"
# Use conda to install pip, numpy
conda install -y -c conda-forge pip numpy
# Help conda resolving Python "import"
conda update --all
Upvotes: 1
Reputation: 96
How are you building your container? You should be able to use pip inside the container just like you would installing on an actual machine.
Here is an example:
Bootstrap: docker
From: python:3.7-alpine
%post
pip install click
Save this as a file, like test.def
, then just build the container:
sudo singularity build test.sif test.def
The build a container document will help.
Upvotes: 2