Search code examples
pythonpython-3.xsingularity-container

How do I install python packages inside of a singularity container?


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?


Solution

  • 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.