Installing Slicer extension from script

I would like to build a Docker container with Slicer 5.0.2 r30822 linux-amd64, and with Slicer extensions installed. To do that, I am trying to have Slicer install extensions from a python script:

emm =
md = emm.retrieveExtensionMetadataByName("DCMQI")
x = emm.downloadAndInstallExtension(md['extension_id'])
if x:
    print('emm completed ok')
    print('emm error', x)

and then run Slicer --python-script "" --no-splash --no-main-window
This does download and install the extension but the script does not exit. If I add sys.exit(0) to the script as suggested here, Slicer exits after downloading the extension, but before installing it. Could you please advise what is the correct way to install Slicer extensions from script?

Thank you,

Here’s an example of installing extensions in a dockerfile with a python script:

Thank you, it works, I also used parts of your Dockerfile (xfvb-run Slicer).

1 Like