Search code examples
pythonfunctionlibraries

if I make a function that calls a library like numpy, and someone else use it, they will need to have numpy installed?


it is very much the title. if I have a code that use a non built-in library in my repository in github and someone copy it, this person will have to have that library installed, right?


Solution

  • Short answer, Yes.

    Long Answer, Yes, but actually you do the following in order to make the script executable on other systems.

    1. Add a requirements.txt file, which specifies the libraries used and needed to be installed. Usually, this is used in a virtual environment. This makes sure that the packages/libraries used will not get mixed up with the main python installation

    2. This is a rough solution, and I would use it in very extreme scenarios. (I used it when I had to run a python code on AWS Lambda where the library I used was compiled in C beforehand.) You can directly copy the Library folder in your code and use it. Mind you, this will increase the code size and is Absolutely not recommended to be done.