当前位置: 首页 > article >正文

项目环境依赖库导出-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

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


http://www.kler.cn/news/283413.html

相关文章:

  • 【Docker】搭建docker的私有仓库
  • centos yum 源停用整改
  • 获取服务器时间
  • 【jvm】局部变量表
  • 轻量级冠军:NVIDIA 发布具有领先准确率的小语言模型
  • Java Excel转PDF(免费)
  • 替换后的最长重复字符(LeetCode)
  • 网络编程(1)
  • 【重点】人工智能大语言模型技术发展研究报告2024|附下载
  • mac安装vue3成功步骤
  • STM32F1+HAL库+FreeTOTS学习7——列表和列表项
  • 养老小程序源码家政服务小程序开发方案
  • C# 爬虫技术:京东视频内容抓取的实战案例分析
  • 设计模式 13 责任链模式
  • 搭建webRTC cotrun流媒体服务器
  • Python中的命令模式:如何设计灵活的命令体系
  • Redis持久化方式、常见问题及解决方案
  • centos安装docker并配置加速器
  • Keil5 Debug模式Watch窗口添加的监控变量被自动清除
  • 【智能算法改进】多策略融合的改进黑猩猩搜索算法及其应用
  • 备忘录模式 详解
  • 电脑强制退出程序快捷键
  • pytorch交叉熵损失函数
  • 效果媲美GPT4V的多模态大型语言模型MiniCPM-V-2_6详细介绍
  • 数据结构(邓俊辉)学习笔记】串 03——KMP算法:记忆法
  • python批量生成sql用于创建500个用户
  • 从数据库中查找单词
  • JAVA电子器件制造行业生产管理系统计算机毕设计算机毕业设计
  • 2024.8.30(使用docker部署project-exam-system)
  • 20.神经网络 - 搭建小实战和 Sequential 的使用