Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listing third party libraries in project

Tags:

python

pip

I've been working on a Python project for a while which uses quite some third party libraries. I want to deploy my project to another server, but I don't know by heart which projects I use and digging through every line of source code would be too much work.

Is there a way to generate a list of third party modules in my project so I can use this with PIP's installer? Thank you for your help

pip install -r dependencies.txt # <-- I need to generate this file from a project
like image 666
Paradoxis Avatar asked Jan 20 '26 19:01

Paradoxis


2 Answers

Provided that you're using a virtual environment to keep your dependencies separate from the globally installed pip packages, you should be able to use pip's freeze command, like so:

pip freeze > dependencies.txt

If you haven't been using a virtual environment, then you probably need to peruse the source code to find the modules. A virtual environment is a means of keeping your python project isolated from the global environment, meaning that you can only import modules that are installed within that environment, and it should only contain modules relevant to its corresponding python project. I recommend that you read up on Virtual Environments, they are very useful for larger projects.

like image 57
kreld Avatar answered Jan 23 '26 07:01

kreld


I ended up writing a python module which does this instead as I couldn't find it. The source code is available on GitHub. You can install it like so:

$ pip install pip-module-scanner

Using it is pretty simple, for full usage examples check the GitHub repo.

$ pip-module-scanner
foo==0.0.1
bar==2.0.0
like image 22
Paradoxis Avatar answered Jan 23 '26 09:01

Paradoxis