Reputation: 30615
I need to use an external Python library (available from Github) in my own Python code.
How do I ensure both myself and other developers (who clone my repo) can execute my code, which calls the external library?
Do I just git clone
the external library to a path within my repo and then import
the library directory from my code?
And this would allow another dev to clone my repo and run my code (including the external library) with no problems?
Nobody has to run a package installer?
Upvotes: 0
Views: 730
Reputation: 2187
If you want to use package in python you need to install it using pip package manager. You can do so using command python -m pip install <packageName>
By default python installs packages with global scope which means that they're available for all python scripts (unless a virtual environment is in use).
When dealing with multiple python projects one can use virtual environments (VENV) to avoid version conflicts and whatnot. This however is a bit more advanced and involved practice which might be a bit of an overkill if you're just looking to write a small script to test or automate something.
When sharing your project or script you list the packages it depends upon using using text file typically named requirements.txt. This allows other developers to install dependencies listed in the file using single command: python -m pip install -r requirements.txt
which then allows them to run the project.
Upvotes: 1