3

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
Paradoxis
  • 4,471
  • 7
  • 32
  • 66

2 Answers2

2

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.

kreld
  • 732
  • 1
  • 5
  • 16
  • 1
    Calling `pip freeze` seems to list all core modules too, I only need a list of third party ones – Paradoxis Aug 09 '16 at 10:59
  • You can either clean up the list or letting pip ignore known ones. In general it's good idea to be as specific as possible with packaets and versions to ensure it's running well. – frlan Aug 10 '16 at 15:05
2

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
Paradoxis
  • 4,471
  • 7
  • 32
  • 66