The simple, quick fix is to have the user install the package in their HOME directory using the something like pip install --user <package> [1]. Long-term, this will likely become unmanageable for the user. i.e., keeping track of what python package was installed
inside a containerized environment or not. So yes, you might also try and setup virtualenvs too to keep things more structured. But again, this assumes users are familiar with how to use virtualenvs though too. It's always a trade off how complicated it needs
to get for them.
[mkandes@comet-ln2 ~]$ singularity shell /share/apps/compute/singularity/images/ubuntu/ubuntu.simg
Singularity> which python
/opt/miniconda3/bin/python
Singularity> python
Python 3.7.4 (default, Aug 13 2019, 20:35:49)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'
>>> exit()
Singularity> which pip
/opt/miniconda3/bin/pip
Singularity> pip install --user numpy
Collecting numpy
|████████████████████████████████| 20.2MB 13.1MB/s
Installing collected packages: numpy
WARNING: The scripts f2py, f2py3 and f2py3.7 are installed in '/home/mkandes/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed numpy-1.18.2
Singularity> python
Python 3.7.4 (default, Aug 13 2019, 20:35:49)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.__version__
'1.18.2'
>>> numpy.__file__
'/home/mkandes/.local/lib/python3.7/site-packages/numpy/__init__.py'
>>>