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
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With