win/unbuntu下python依赖

本文介绍了在Windows和Ubuntu操作系统下,如何使用pip和conda管理Python环境的依赖。包括如何导出和安装requirements文件,以及解决下载特定版本包时可能出现的问题。遇到包不存在的情况,可以通过更换下载源如豆瓣镜像来解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

win/unbuntu下python依赖

  • pip导出项目依赖包
#输出安装的包和版本信息
pip freeze
#将上述结果输出重定向到requirements.txt中保存
pip freeze > requirements.txt
  • pip批量安装requirements.txt中指定的包
pip install -r requirements.txt
  • conda批量导出
conda list -e > requirements.txt
  • conda批量安装
conda install --yes --file requirements.txt
  • 遇到的问题
    有时候下包会出现不存在指定版本的情况
    不存在指定版本的情况
    更换源地址,例如
#添加豆瓣镜像源下载指定版本 -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com/simple
pip install opencv-python==3.4.8.29 -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com/simple
Traceback (most recent call last): File "/home/unbuntu/anaconda3/envs/My_torch/lib/python3.8/site-packages/git/__init__.py", line 296, in <module> refresh() File "/home/unbuntu/anaconda3/envs/My_torch/lib/python3.8/site-packages/git/__init__.py", line 287, in refresh if not Git.refresh(path=path): File "/home/unbuntu/anaconda3/envs/My_torch/lib/python3.8/site-packages/git/cmd.py", line 631, in refresh raise ImportError(err) ImportError: Bad git executable. The git executable must be specified in one of the following ways: - be included in your $PATH - be set via $GIT_PYTHON_GIT_EXECUTABLE - explicitly set via git.refresh(<full-path-to-git-executable>) All git commands will error until this is rectified. This initial message can be silenced or aggravated in the future by setting the $GIT_PYTHON_REFRESH environment variable. Use one of the following values: - quiet|q|silence|s|silent|none|n|0: for no message or exception - warn|w|warning|log|l|1: for a warning message (logging level CRITICAL, displayed by default) - error|e|exception|raise|r|2: for a raised exception Example: export GIT_PYTHON_REFRESH=quiet The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/unbuntu/yolov5-master/train.py", line 100, in <module> GIT_INFO = check_git_info() File "/home/unbuntu/anaconda3/envs/My_torch/lib/python3.8/contextlib.py", line 75, in inner return func(*args, **kwds) File "/home/unbuntu/yolov5-master/utils/general.py", line 405, in check_git_info import git File "/home/unbuntu/anaconda3/envs/My_torch/lib/python3.8/site-packages/git/__init__.py", line 298, in <module> raise ImportError("Failed to initialize: {0}".format(_exc)) from _exc ImportError: Failed to initialize: Bad git executable. The git executable must be specified in one of the following ways: - be included in your $PATH - be set via $GIT_PYTHON_GIT_EXECUTABLE - explicitly set via git.refresh(<full-path-to-git-executable>) All git commands will error until this is rectified. This initial message can be silenced or aggravated in the future by setting the $GIT_PYTHON_REFRESH environment variable. Use one of the following values: - quiet|q|silence|s|silent|none|n|0: for no message or exception - warn|w|warning|log|l|1: for a warning message (logging level CRITICAL, displayed by default) - error|e|exception|raise|r|2: for a raised exception Example: export GIT_PYTHON_REFRESH=quiet终端信息如上。请说明yolo5在执行train.py后没有生成result文本的原因和解决方法(执行detect.py只生成图片,没有文本)
最新发布
07-06
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值