Python使用conda如何安装requirement.txt的扩展包
作者:爱听许嵩歌 发布时间:2022-03-13 23:01:18
标签:Python,conda,requirement.txt,扩展包
使用conda安装requirement.txt的扩展包
当你在GitHub上下载了代码时,可以看到有一个requirements.txt文件,这是这个Python环境需要配置的扩展包,该文件记录了当前程序的所有依赖包及其精确版本号。
你可以打开文件,然后用conda install一个一个的安装包,或者按下面的操作来:
生成requirements.txt文件
用conda activate 你的环境名字,此时进入了你的环境中,然后使用代码:
pip freeze > requirements.txt
就会生成一个所需环境包的txt文件,我的一个环境包含的包如下:
backcall==0.1.0
beautifulsoup4==4.9.0
bleach==3.1.4
certifi==2020.4.5.2
colorama==0.4.3
cycler==0.10.0
decorator==4.4.2
defusedxml==0.6.0
entrypoints==0.3
ipykernel==5.1.4
ipython==7.13.0
ipython-genutils==0.2.0
jedi==0.17.0
Jinja2==2.11.2
joblib==0.15.1
jsonschema==2.6.0
jupyter-client==5.3.3
jupyter-contrib-core==0.3.3
jupyter-contrib-nbextensions==0.5.1
jupyter-core==4.5.0
jupyter-highlight-selected-word==0.2.0
jupyter-latex-envs==1.4.6
jupyter-nbextensions-configurator==0.4.1
jupyterthemes==0.20.0
kiwisolver==1.2.0
lesscpy==0.14.0
line-profiler==2.1.2
lxml==4.5.0
MarkupSafe==1.1.1
matplotlib==3.1.3
memory-profiler==0.55.0
mistune==0.8.4
mkl-fft==1.0.14
mkl-random==1.0.4
mkl-service==2.3.0
msgpack==0.6.2
nb-conda==2.2.1
nb-conda-kernels==2.2.3
nbconvert==5.6.1
nbformat==5.0.6
notebook==6.0.1
numpy==1.17.0
pandas==1.0.3
pandocfilters==1.4.2
parso==0.7.0
patsy==0.5.1
pickleshare==0.7.5
ply==3.11
prometheus-client==0.7.1
prompt-toolkit==3.0.4
psutil==5.7.0
Pygments==2.6.1
pyparsing==2.4.7
python-dateutil==2.8.1
pytz==2020.1
pywin32==227
pywinpty==0.5.7
PyYAML==5.3.1
pyzmq==18.1.1
scikit-learn==0.22.1
scipy==1.4.1
seaborn==0.10.1
Send2Trash==1.5.0
six==1.14.0
soupsieve==2.0.1
statsmodels==0.11.1
terminado==0.8.3
testpath==0.4.4
tornado==6.0.4
traitlets==4.3.3
wcwidth==0.1.9
webencodings==0.5.1
wincertstore==0.2
安装requirement.txt文件的扩展包
pip install -r requirements.txt
除了使用pip命令来生成及安装requirement.txt文件以外,也可以使用conda命令来安装。
conda install --yes --file requirements.txt
但是这里存在一个问题,如果requirements.txt中的包不可用,则会抛出“无包错误”。
使用下面这个命令可以解决这个问题
$ while read requirement; do conda install --yes $requirement; done < requirements.txt
如果想要在conda命令无效时使用pip命令来代替,那么使用如下命令:
$ while read requirement; do conda install --yes $requirement || pip install $requirement; done < requirements.txt
有时可以导出conda环境,导出格式为.yml文件
conda env export > requirements.yml
此时你的电脑需要这个conda环境,可以直接用这个yml文件在你的电脑上创造出一个同名字,同扩展包的环境,你只需要进入cmd,然后直接运行下面代码就可以了:
conda env create -f requirements.yml
生成requirement.txt及requirements.txt安装包
生成requirements.txt问题
执行下面这句命令后,就可在当前目录看见文件requirements.txt
pip freeze > requirements.txt
使用requirements.txt安装包
pip install -r requirements.txt
来源:https://blog.csdn.net/weixin_45092662/article/details/106906719


猜你喜欢
- 1、现象系统提示找不到指定的文件:Error running 'hello': Cannot run program &qu
- What do the ->, => and :: symbols mean?The -> is the "in
- 定义通用视图修改 book/models.py 代码中的 AuthorInfo 类,如果一致则不必修改class AuthorInfo(mo
- 本文实例总结了Python2与Python3的区别。分享给大家供大家参考,具体如下:Python的3??.0版本相对于Python的早期版本
- 春节来到,红包们大概率在微信各大群中肆虐,大家是否都一样不抢到红包们心里就感觉错过了一个亿,可总会被这事那事耽误而遗憾错过,下面用 Pyth
- mycliMyCLI is a command line interface for MySQL, MariaDB, and Percona
- 创建py文件总是为txt格式问题记录写代码过程中创建.py文件时,一直正常,但创建名称为train.py文件时总是为txt格式,即使选择了p
- 当我们使用访问一个没有声明的变量时,JS会报错;而当我们给一个没有声明的变量赋值时,JS不会报错误,相反它会认为我们是要隐式申明一个全局变量
- 1,新建一个项目File --> New Project...2,新建一个文件右键单击刚建好的helloWord项目,选择New --
- DATAFRAME中使用iat[1,0]和iloc[0,1]对元素进行修改。a = [("hahaha",1),(&qu
- asp上传的时候出现这种 错误:Server 对象 错误 'ASP 0177 800401f3'Server.CreateO
- 有向无环图拓扑排序是针对有向无环图(DAG, Directed Acyclic Graph)的具有以下性质:如果这个图不是 DAG,那么它是
- 通过navicat客户端修改datetime默认值时,遇到了问题。数据库表字段类型datetime,原来默认为NULL,当通过界面将默认值设
- 因此,常常出现这样的错误select * from [IND] where INDID>10unionselect * from [I
- 我们再用Jupyter-notebook,ipython-console,qtconsole的时候,有的时候画图希望不弹出窗口,直接画在co
- 一、条件变量与互斥锁条件变量是基于互斥锁的,它必须基于互斥锁才能发挥作用;条件变量并不是用来保护临界区和共享资源的,它是用来协调想要访问共享
- 一、前言 axios的封装和api接口的统一管理,其实主要目的就是在帮助我们简化代码和利于后期的更新维护。二、axios封装步骤安
- 查到的可能原因:1.本地的go编译器版本2. go module构建模式未开启3. 是否在go.mod所在目录执行的go mod tidy解
- 函数是一组可重用的代码,可以在程序的任何地方被调用。这消除了一次又一次地写入相同的代码的需要。这将帮助程序员编写模块化代码。您可
- 介绍反射是元数据编程的一种形式,指的是程序获得本身结构的一种能力。不同语言的反射模型实现不一样,本文中的反射,仅仅指的是Go语言中的反射模型