For my project I am only needing to import the stats and optimize module from Scipy. I would like to know if it is possible to install only these modules with pip? What alternatives do I have?
I would like to know if it is possible to install only these modules with pip?
No. Pip only supports installing or uninstalling entire packages, not parts of packages.
What alternatives do I have?
Fork SciPy, and modify it to remove all code outside scipy.stats
, and replace references within scipy.stats
to the rest of SciPy with your own code.
Here are three examples of the kinds of problems you'd need to fix:
scipy.stats
uses scipy.optimize.fsolve
to fit distributions to data points.scipy.stats
uses scipy.linalg.cho_solve
to compute covariance.scipy.stats
uses scipy.special.ndtr
when computing the CDF of a normal distribution.In each of these cases, you'd need to either 1) include the code it's referencing, including anything it references, 2) remove that feature or 3) provide your own implementation of the functionality.
These are three examples - there are 82 places where code in scipy.stats
imports code outside of scipy.stats
. You would probably need to solve about 79 more problems like this in order to get this to work. In some sense this is possible. However, I can't imagine that this would be worth the trouble.
If you're still interested in doing this, I recommend reading the SciPy documentation on building from source as a first step. Since some of the references are in compiled code, you'll need to be able to build from source.