项目环境依赖库导出-python

对于python语言建议不同的任务或项目中建立单独的虚拟环境,对于其他的语言最好也是不同的任务配置不同环境,而在虚拟环境中会使用的很多依赖和库,这时候别人使用的时候如果不知道需要安装哪些库会很麻烦,这时候的一个需求就是,如何导出项目代码中所实际使用到的库及其版本。
利用pipreqs库可以方便完成以上需求。操作如下:
安装

pip install pipreqs -i https://pypi.tuna.tsinghua.edu.cn/simple

注意:如果你不需要支持 Jupyter Notebook,你可以安装一个不包含相关依赖的版本

pip install --no-deps pipreqs
pip install yarg==0.1.9 docopt==0.6.2

使用:

Usage:
    pipreqs [options] [<path>]

Arguments:
    <path>                The path to the directory containing the application files for which a requirements file
                          should be generated (defaults to the current working directory)

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, each separated by a comma
    --no-follow-links     Do not follow symbolic links in the project
    --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
    --mode <scheme>       Enables dynamic versioning with <compat>, <gt> or <non-pin> schemes
                          <compat> | e.g. Flask~=1.1.2
                          <gt>     | e.g. Flask>=1.1.2
                          <no-pin> | e.g. Flask
    --scan-notebooks      Look for imports in jupyter notebook files.

示例:

pipreqs /home/project/location

欢迎点赞,收藏,关注,支持小生,打造一个好的遥感领域知识分享专栏。遥感专栏
同时欢迎私信咨询讨论学习,咨询讨论的方向不限于:地物分类/语义分割(如水体,云,建筑物,耕地,冬小麦等各种地物类型的提取),变化检测,夜光遥感数据处理,目标检测,图像处理(几何矫正,辐射矫正(大气校正),图像去噪等),遥感时空融合,定量遥感(土壤盐渍化/水质参数反演/气溶胶反演/森林参数(生物量,植被覆盖度,植被生产力等)/地表温度/地表反射率等反演)以及高光谱数据处理等领域以及深度学习,机器学习等技术算法讨论,以及相关实验指导/论文指导,考研复习等多方面。

你可能感兴趣的:(python,开发语言,#遥感,图像处理)