美文网首页
Ubuntu系统常用指令

Ubuntu系统常用指令

作者: wo虾仁猪心de | 来源:发表于2022-07-31 17:23 被阅读0次

    1、生成python项目的requeirement.txt文件

    1)安装pipreqs
    pip3 install pipreqs
    2)在本地生成requirements文件,这里有两种方式
    pip3 freeze > requirements.txt
    pipreqs . --encoding=utf8 --force
    推荐切换至需迁移项目的根目录,使用第二种命令。该命令会生成当前项目中所有的依赖,未使用的python依赖和类库将不会被生成。
    PS:

    1.使用第二种方式生成requirements时一定要确保项目中的所有类库都被正确安装了,否则pipreqs 会报错,无法正常生成requirements文件。
    2.请留意自己的python版本,一般来说python2使用pip,python3使用pip3命令。

    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.
    

    相关文章

      网友评论

          本文标题:Ubuntu系统常用指令

          本文链接:https://www.haomeiwen.com/subject/pvszprtx.html