Automatic install of Python packages

On mac (and probably linux) this works:

>>> import os
>>> os.system('PythonSlicer -m pip install pandas')
0
>>> import pandas

On windows, this process pops up the access control permission dialog:

import os
os.system('powershell.exe Start-Process cmd.exe -Verb runAs')

And then in the shell I could run this:

"c:\Program Files\Slicer 4.11.0-2019-06-02\bin\PythonSlicer.exe" -m pip install pandas

We should be able to streamline this and integrate it with the extension install process.

We discussed this on the developer call the other day and were thinking we should start collecting this information along with guidelines about which python packages should work and which might cause trouble.

2 Likes