pip / conda 导出和安装环境组件 requirements.txt

本文介绍如何使用pip和conda工具批量导出及安装Python环境中的依赖包。通过pipfreeze和condalist命令生成requirements.txt文件,再利用pipinstall和condainstall进行依赖安装。

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

pip 批量导出包含环境中所有组件的requirements.txt文件

pip freeze > requirements.txt

pip 批量安装requirements.txt文件中包含的组件依赖

pip install -r requirements.txt

pip 导出的requirements.txt文件格式

absl-py==0.2.0
astor==0.6.2
bleach==1.5.0
boto==2.48.0
boto==31.7.19
botocore==1.10.19
bz2file==0.98
certifi==2018.4.16
chardet==3.0.4
cycler==0.10.0
Cython==0.28.2
docutils==0.14
fasttext==0.8.3
future==0.16.0
gast==0.2.0
gensim==3.4.0
grpcio==1.11.0
h5py==2.7.1
html5lib==0.9999999

 

 

 

 

conda 批量导出包含环境中所有组件的requirements.txt文件

conda list -e > requirements.txt

conda 批量安装requirements.txt文件中包含的组件依赖

conda install --yes --file requirements.txt    #这种执行方式,一遇到安装不上就整体停止不会继续下面的包安装
FOR /F "delims=~" %f in (requirements.txt) DO conda install --yes "%f" #这个执行能解决上面出现的不执行后续包的问题

conda 导出的requirements.txt文件格式

# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: win-64
absl-py=0.7.1=pypi_0
astor=0.7.1=pypi_0
certifi=2018.8.24=py35_1 gast=0.2.2=pypi_0 grpcio=1.19.0=pypi_0 h5py=2.9.0=pypi_0 keras-applications=1.0.7=pypi_0 keras-preprocessing=1.0.9=pypi_0 markdown=3.1=pypi_0 mock=2.0.0=pypi_0 numpy=1.16.2=pypi_0 pbr=5.1.3=pypi_0 pip=19.0.3=pypi_0 protobuf=3.7.1=pypi_0 python=3.5.6=he025d50_0 setuptools=40.2.0=py35_0 six=1.12.0=pypi_0 tensorboard=1.13.1=pypi_0 tensorflow=1.13.1=pypi_0 tensorflow-estimator=1.13.0=pypi_0 termcolor=1.1.0=pypi_0 vc=14.1=h0510ff6_4 vs2015_runtime=14.15.26706=h3a45250_0 werkzeug=0.15.1=pypi_0 wheel=0.31.1=py35_0 wincertstore=0.2=py35hfebbdb8_0

 

转载于:https://www.cnblogs.com/maxiaodoubao/p/10605850.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值