5

I have a Singularity container with many tools along with Python and Jupyter installed in it. But I want to access the external virtual environments I have created for python while using the other tools in Singularity. The reason being I am experimenting with different python packages which cannot be installed into Singularity container without 'sudo' privileges. And I cannot install the other tools on my host machine due to sudo privileges.

I am able to activate the virtual environment but not able to use it: Get this error when I run pip command or Jupyter lab.

bash: /home/username/virtual-env/bin/pip: /home/username/virtual-env/bin/python: bad interpreter: No such file or directory

I want to run Jupyter lab from the virtual environment which is run from the Singularity container.

kosmos
  • 359
  • 5
  • 13

1 Answers1

1

I've had success by mounting certain bin directories from the host onto directories in the Singularity container when activating the container, and thus accessible from within the container.

Example: Mount /data from host to /mnt in my_container

$ singularity shell --bind /data:/mnt my_container.sif

Source: Singularity Documentation

Fortunately, the bin on host were automatically mapped to certain Singularity container mount points as configured by my administrator.

Thus, perhaps one workaround if your admin doesn't allow you to bind paths would be to create symlink (pointing to the bin you need) on your host in the directories that are automatically bound (i.e., $HOME, /tmp, /proc, /sys, /dev).

qwerty
  • 101
  • 1
  • 9