pipreqs

2020-04-05  本文已影响0人  飞行睿客

一、说明

使用 pipreqs 可以自动检索到当前项目下的所有组件及其版本,并生成 requirements.txt 文件,极大方便了项目迁移和部署的包管理。相比直接用 requirements.txt 命令,能直接隔离其它项目的包生成。

二、安装

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
    --diff <file>         Compare modules in requirements.txt to project imports.
    --clean <file>        Clean up requirements.txt by removing modules that are not imported in project.
    --no-pin              Omit version of output packages.

执行 pipreqs 命令

# Successfully saved requirements file in /home/project/location/requirements.txt
$ pipreqs /home/project/location

四、项目执行

> pipreqs ./ --encoding=utf-8
> pipreqs . --encoding=utf-8
> pipreqs ./ --encoding=utf-8 --force

五、参考文档

https://pypi.org/project/pipreqs/

上一篇下一篇

猜你喜欢

热点阅读