How to use different virtual environment for server-side OMERO scripts?

I’m working on some server-side OMERO scripts for image segmentation, which require packages not found in the standard OMERO python virtual environment (e.g., PyTorch). The easiest way to install all of the desired packages was within a separate anaconda virtual environment. Is there a way to have a server-side script run from within this environment? It seems as though it defaults to the omero-web environment. I did try setting the shebang to the conda environment #!/home/miniconda3/envs/env/bin/python, but that didn’t seem to work.

Hi Jonathan,

The omero.launcher.python configuration variable defines which Python executable will be used by scripts. It defaults to sys.executable. You can try pointing it to the Python executable in your conda environment but this is not something I’ve tested. It may be necessary to use a wrapper script which activates the entire environment.

All the best,
~Josh

Thanks @joshmoore. Changing the omero.launcher.python to point to the conda environment seemed to work. I modified my Ansible configuration as follows:

omero_server_config_set:
  omero.launcher.python: /home/user/miniconda3/envs/env/bin/python3
1 Like