I am developing a Scripted Loadable Module that utilizes several external Python modules, specifically scipy, sklearn, and PyWavelets.
Currently, the module has the below script written along with its import statements:
pip_modules = ['scipy', 'sklearn', 'PyWavelets']
for module_ in pip_modules:
try:
module_obj = __import__(module_)
except ImportError:
logging.info("{0} was not found.\n Attempting to install {0} . . ."
.format(module_))
pip_main(['install', module_])
However, I feel this is an ugly and perhaps unacceptable way to do this.
Is there a proper or preferred “Slicery” way for me to check if these modules exist and install them if they do not?
The main approach I have been looking at was using the cmake files, but I have not had any success in that area.