pythondockersingularity-container

Singularity: Python package not available even though it is in docker


I built myself a docker image from this docker file:

FROM ubuntu:22.04

RUN apt-get update
RUN apt-get upgrade -y

# Install python: 
RUN apt-get install software-properties-common -y
RUN add-apt-repository ppa:deadsnakes/ppa -y
RUN apt-get update 
RUN DEBIAN_FRONTEND=noninteractive apt-get install python3.11 -y
RUN python3 --version
RUN apt-get upgrade

# Install pip: 
RUN apt-get install python3-pip -y 

# Install disba (https://github.com/keurfonluu/disba/): 
RUN pip install disba[full] --user

(disba is a Python package used for the modeling of surface wave dispersions, and I need this package).

I noticed that when I try importing disba in python3 from a docker container, it works, but when I try to do the same thing in singularity (which is installed on our HPC cluster), it complains:

Singularity> python3
Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import disba
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'disba'

(The way I built the singularity container is by pushing my docker image to dockerhub and then doing

singularity build <container_name> docker://<docker_url>

followed by

singularity run <container_name>

) Unfortunately, I'm at a loss to understand why I cannot import the module I need... I'd appreciate any hints or ideas.

EDIT: Commenting on the answer by @Henrique Andrade: i) When I type python3.11 in singularity and then try importing disba, the error persists. ii) Also in docker, when I type python3, Python 3.10.6 is started, but importing disba works, so it doesn't seem to be an issue with the Python version.


Solution

  • When you install disba with RUN pip install disba[full] --user you are potentially installing it in a user account that is not the same that the Singularity image is going to use.

    I would install without --user, to install the package globally.