How can I find all packages and their version used in my project?

I have a python project and I want to write "requirements" for it. So I need to find all the packages used in my project. Is there an easy way to do this?

+3


source to share


3 answers


pipreqs

pip freeze list all installed packages, use pipreqs. Pipreqs generates a .txt file for any import based project.



pip install pipreqs


Usage:
    pipreqs [options] <path>

Options:
    --use-local           Use ONLY local package info instead of querying PyPI
    --pypi-server <url>   Use custom PyPi server
    --proxy <url>         Use Proxy, parameter will be passed to requests library. You can also just set the
                          environments parameter in your terminal:
                          $ export HTTP_PROXY="http://10.10.1.10:3128"
                          $ export HTTPS_PROXY="https://10.10.1.10:1080"
    --debug               Print debug information
    --ignore <dirs>...    Ignore extra directories
    --encoding <charset>  Use encoding parameter for file open
    --savepath <file>     Save the list of requirements in the given file
    --print               Output the list of requirements in the standard output
    --force               Overwrite existing requirements.txt

      

Github project

+6


source


You can do this by running pip freeze > requirements.txt

. I suggest going through here here as it is explained.

The command pip freeze

executes, according to the documentation :



Output installed packages in requirements format.

      

so on startup pip freeze > requirements.txt

you write the installed packages to a file .txt

.

+1


source


original answer from my comment:

You can use pip freeze to list all installed packages with a specific version:

pip freeze > requirements.txt

      

This will work well, especially if you are using virtualenv . If not, and you only want to view the packages requested in a specific project, consider @ Sidon's answer .

-1


source







All Articles