1

I have created a private package and i want to use a module from that package on one script. It is possible to install only the necessary dependencies to run that module or I have to install the whole package always?

I will use my script inside a docker container. I can extract the code from the library, but this will make my code not maintainable in the long term.

For example, if I want to use a linear regression from scikit-learn it will be an overkill to install the whole library. The image will be so heavy!

Fran Arenas
  • 639
  • 6
  • 18
  • 2
    No, there is no general option to only install part of a Python package. You generally package up what can be used independently, in a single package. – Martijn Pieters Aug 18 '21 at 12:46
  • Does this answer your question ? https://stackoverflow.com/questions/53818607/is-it-possible-to-install-part-of-python-package-via-pip/53818728 – Haha Aug 18 '21 at 13:31

1 Answers1

1

No, you cannot install 1 module from whole package because even the LinearRegression from scikit-learn is dependent on another math modules and evaluators from this library.

But you can create your own linear regression. Here is a great example: https://towardsdatascience.com/linear-regression-with-python-and-numpy-25d0e1dd220d

Andrii Syd
  • 308
  • 5
  • 15
  • The linear regression was only an example. So, as I see, the only way will be to clone the repository and remove all the files that are not related to the particular module... Not very clean, but at least it will work. – Fran Arenas Aug 18 '21 at 12:57