Hi everyone,
Is there a way to install a python package in slicer’s python environment (using pip) but not during the runtime of Slicer. What would be the cleanest way to do it?
Thanks for your advices,
Pierre
Hi everyone,
Is there a way to install a python package in slicer’s python environment (using pip) but not during the runtime of Slicer. What would be the cleanest way to do it?
Thanks for your advices,
Pierre
In the Slicer binary folder there is PythonSlicer.exe which you can use like you would a system python install python packages into slicer’s python environment. PythonSlicer.exe -m pip install X
.
Are you asking how to do this not during runtime of Slicer because you are changing the version of a python package that is in Slicer core? If so, this could lead to some incompatibilities as Slicer is tested primarily on the specific versions included.
If you’re looking to install a python package as required by a module, but you don’t want to do it during Slicer run-time you could package the python package at time of building the extension. See SlicerRadiomics of how they package pyradiomics
with the extension.
Hi James,
Thank you for your input.
The last paragraph, probably what we are looking for. For instance, how we can install scipy at building stage.
I will look at it !
Cheers,
Using pip install to install scipy indicates you are likely wanting the whl file as provided by PyPI. Slicer already by default contains Scipy as you shouldn’t need to install it again. Is there something wrong with this already included version?
sorry, scipy was just for the example. I need to install weasypdf.
There is no such package on PyPI. Are you sure this is the correct name?
Maybe documentation is not up-to-date but there is First Steps — WeasyPrint 53.2 documentation
This (weasyprint
) is a different package. You wrote you were trying to install the non-existing weasypdf
package.
sorry about that… I will post my solution here.
Well, I am really struggling to understand Cmake and the way it could be done. Could you help me on that, please ?
Would you like to bundle the Python package in an extension or in a custom Slicer application?
In a custom slicer application
For a Slicer custom app you can use SlicerSalt as an example. See the following below how some python packages are installed as part of the superbuild process.