【Trick】conda指令安装yml文件中的python依赖

2024-05-04 14:44

本文主要是介绍【Trick】conda指令安装yml文件中的python依赖,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

安装python依赖通常使用【pip】或【conda】指令,pip主要用于txt文件,conda主要用于yml文件。以下将给出其使用方法

pip

首先,创建一个YAML文件,列出python依赖项。

dependencies:- python=3.8- numpy- pandas- matplotlib

然后,打开终端,运行pip指令(假设文件名为requirements,实际应用时下列指令应该根据文件名进行修改)。

对于yml:

pip install -r requirements.yml

对于txt:

pip install -r requirements.txt

后续只需等待即可。 

conda

 首先,创建一个YAML文件,列出python依赖项。

channels:- defaults
dependencies:- python=3.8- numpy- pandas- matplotlib

然后,打开终端,运行conda指令(假设文件名为requirements,实际应用时下列指令应该根据文件名进行修改)。

对于yml:

conda env create -f requirements.yml

后续只需等待即可。 

实际案例

yml文件内容如下:

name: con_110
channels:- pytorch- defaults
dependencies:- _libgcc_mutex=0.1=main- _openmp_mutex=4.5=1_gnu- backcall=0.2.0=pyhd3eb1b0_0- blas=1.0=mkl- bzip2=1.0.8=h7b6447c_0- ca-certificates=2022.07.19=h06a4308_0- certifi=2022.9.24=py37h06a4308_0- cudatoolkit=11.3.1=h2bc3f7f_2- debugpy=1.5.1=py37h295c915_0- decorator=5.1.1=pyhd3eb1b0_0- entrypoints=0.4=py37h06a4308_0- faiss-gpu=1.7.2=py3.7_h28a55e0_0_cuda11.3- ffmpeg=4.3=hf484d3e_0- freetype=2.11.0=h70c0345_0- giflib=5.2.1=h7b6447c_0- gmp=6.2.1=h2531618_2- gnutls=3.6.15=he1e5248_0- intel-openmp=2021.4.0=h06a4308_3561- ipykernel=6.15.2=py37h06a4308_0- ipython=7.31.1=py37h06a4308_1- jedi=0.18.1=py37h06a4308_1- joblib=1.1.0=pyhd3eb1b0_0- jpeg=9d=h7f8727e_0- jupyter_client=7.1.2=pyhd3eb1b0_0- jupyter_core=4.11.1=py37h06a4308_0- lame=3.100=h7b6447c_0- lcms2=2.12=h3be6417_0- ld_impl_linux-64=2.35.1=h7274673_9- libfaiss=1.7.2=hfc2d529_0_cuda11.3- libffi=3.3=he6710b0_2- libgcc-ng=9.3.0=h5101ec6_17- libgfortran-ng=7.5.0=ha8ba4b0_17- libgfortran4=7.5.0=ha8ba4b0_17- libgomp=9.3.0=h5101ec6_17- libiconv=1.15=h63c8f33_5- libidn2=2.3.2=h7f8727e_0- libpng=1.6.37=hbc83047_0- libsodium=1.0.18=h7b6447c_0- libstdcxx-ng=9.3.0=hd4cf53a_17- libtasn1=4.16.0=h27cfd23_0- libtiff=4.2.0=h85742a9_0- libunistring=0.9.10=h27cfd23_0- libuv=1.40.0=h7b6447c_0- libwebp=1.2.2=h55f646e_0- libwebp-base=1.2.2=h7f8727e_0- lz4-c=1.9.3=h295c915_1- matplotlib-inline=0.1.6=py37h06a4308_0- mkl=2021.4.0=h06a4308_640- mkl-service=2.4.0=py37h7f8727e_0- mkl_fft=1.3.1=py37hd3c417c_0- mkl_random=1.2.2=py37h51133e4_0- ncurses=6.3=h7f8727e_2- nest-asyncio=1.5.5=py37h06a4308_0- nettle=3.7.3=hbbd107a_1- numpy=1.21.2=py37h20f2e39_0- numpy-base=1.21.2=py37h79a1101_0- olefile=0.46=py37_0- openh264=2.1.1=h4ff587b_0- openssl=1.1.1q=h7f8727e_0- packaging=21.3=pyhd3eb1b0_0- parso=0.8.3=pyhd3eb1b0_0- pexpect=4.8.0=pyhd3eb1b0_3- pickleshare=0.7.5=pyhd3eb1b0_1003- pillow=8.4.0=py37h5aabda8_0- pip=21.2.2=py37h06a4308_0- prompt-toolkit=3.0.20=pyhd3eb1b0_0- ptyprocess=0.7.0=pyhd3eb1b0_2- py=1.11.0=pyhd3eb1b0_0- pygments=2.11.2=pyhd3eb1b0_0- pyparsing=3.0.9=py37h06a4308_0- python=3.7.11=h12debd9_0- python-dateutil=2.8.2=pyhd3eb1b0_0- pytorch=1.10.2=py3.7_cuda11.3_cudnn8.2.0_0- pytorch-mutex=1.0=cuda- pyzmq=22.3.0=py37h295c915_2- readline=8.1.2=h7f8727e_1- scikit-learn=1.0.2=py37h51133e4_1- scipy=1.7.3=py37hc147768_0- setuptools=58.0.4=py37h06a4308_0- six=1.16.0=pyhd3eb1b0_1- sqlite=3.37.2=hc218d9a_0- threadpoolctl=2.2.0=pyh0d69192_0- tk=8.6.11=h1ccaba5_0- torchvision=0.11.3=py37_cu113- tornado=6.1=py37h27cfd23_0- tqdm=4.62.3=pyhd3eb1b0_1- traitlets=5.1.1=pyhd3eb1b0_0- typing_extensions=3.10.0.2=pyh06a4308_0- wcwidth=0.2.5=pyhd3eb1b0_0- wheel=0.37.1=pyhd3eb1b0_0- xz=5.2.5=h7b6447c_0- zeromq=4.3.4=h2531618_0- zlib=1.2.11=h7f8727e_4- zstd=1.4.9=haebb681_0- pip:- charset-normalizer==2.0.12- click==8.0.4- docker-pycreds==0.4.0- gitdb==4.0.9- gitpython==3.1.27- idna==3.3- importlib-metadata==4.11.1- pathtools==0.1.2- promise==2.3- protobuf==3.19.4- psutil==5.9.0- pyyaml==6.0- requests==2.27.1- sentry-sdk==1.5.6- shortuuid==1.0.8- smmap==5.0.0- termcolor==1.1.0- urllib3==1.26.8- wandb==0.12.10- yaspin==2.1.0- zipp==3.7.0

conda指令如下:

conda env create -f environment.yml

运行过程如下:

(base) ubuntu@xwk2:~/GG$ conda env create -f environment.yml
Retrieving notices: ...working... done
Collecting package metadata (repodata.json): - WARNING conda.models.version:get_matcher(556): Using .* with relational operator is superfluous and deprecated and will be removed in a future version of conda. Your spec was 1.7.1.*, but conda is ignoring the .* and treating it as 1.7.1
WARNING conda.models.version:get_matcher(556): Using .* with relational operator is superfluous and deprecated and will be removed in a future version of conda. Your spec was 1.9.0.*, but conda is ignoring the .* and treating it as 1.9.0
WARNING conda.models.version:get_matcher(556): Using .* with relational operator is superfluous and deprecated and will be removed in a future version of conda. Your spec was 1.8.0.*, but conda is ignoring the .* and treating it as 1.8.0
WARNING conda.models.version:get_matcher(556): Using .* with relational operator is superfluous and deprecated and will be removed in a future version of conda. Your spec was 1.6.0.*, but conda is ignoring the .* and treating it as 1.6.0
done
Solving environment: done==> WARNING: A newer version of conda exists. <==current version: 23.7.3latest version: 24.4.0Please update conda by running$ conda update -n base -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main condaOr to minimize the number of packages updated during conda update useconda install conda=24.4.0Downloading and Extracting Packages
blas-1.0             | 6 KB      | ############################################################################## | 100% 
certifi-2022.9.24    | 154 KB    | ############################################################################## | 100% 
setuptools-58.0.4    | 775 KB    | ############################################################################## | 100% 
numpy-base-1.21.2    | 4.8 MB    | ############################################################################## | 100% 
ipykernel-6.15.2     | 189 KB    | ############################################################################## | 100% 
prompt-toolkit-3.0.2 | 259 KB    | ############################################################################## | 100% 
pygments-2.11.2      | 759 KB    | ############################################################################## | 100% 
python-3.7.11        | 45.3 MB   | ############################################################################## | 100% 
pyzmq-22.3.0         | 465 KB    | ############################################################################## | 100% 
libunistring-0.9.10  | 536 KB    | ############################################################################## | 100% 
entrypoints-0.4      | 16 KB     | ############################################################################## | 100% ... (more hidden) ...Preparing transaction: done                                                                                              
Verifying transaction: done                                                                                              
Executing transaction: \ By downloading and using the CUDA Toolkit conda packages, you accept the terms and conditions of the CUDA End User License Agreement (EULA): https://docs.nvidia.com/cuda/eula/index.html                                \                                                                                                                        Installed package of scikit-learn can be accelerated using scikit-learn-intelex.                                     More details are available here: https://intel.github.io/scikit-learn-intelex                                        For example:      $ conda install scikit-learn-intelex$ python -m sklearnex my_application.pydone
Installing pip dependencies: \ Ran pip subprocess with arguments:
['/home/ubuntu/miniconda3/envs/con_110/bin/python', '-m', 'pip', 'install', '-U', '-r', '/home/ubuntu/GLC/condaenv.h1f9e76a.requirements.txt', '--exists-action=b']
Pip subprocess output:
Collecting charset-normalizer==2.0.12Downloading charset_normalizer-2.0.12-py3-none-any.whl (39 kB)
Collecting click==8.0.4Downloading click-8.0.4-py3-none-any.whl (97 kB)
Collecting docker-pycreds==0.4.0Downloading docker_pycreds-0.4.0-py2.py3-none-any.whl (9.0 kB)
Collecting gitdb==4.0.9Downloading gitdb-4.0.9-py3-none-any.whl (63 kB)
Collecting gitpython==3.1.27Downloading GitPython-3.1.27-py3-none-any.whl (181 kB)
Collecting idna==3.3Downloading idna-3.3-py3-none-any.whl (61 kB)
Collecting importlib-metadata==4.11.1Downloading importlib_metadata-4.11.1-py3-none-any.whl (17 kB)
Collecting pathtools==0.1.2Downloading pathtools-0.1.2.tar.gz (11 kB)
Collecting promise==2.3Downloading promise-2.3.tar.gz (19 kB)
Collecting protobuf==3.19.4Downloading protobuf-3.19.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB)
Collecting psutil==5.9.0Downloading psutil-5.9.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (280 kB)
Collecting pyyaml==6.0Downloading PyYAML-6.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (596 kB)
Collecting requests==2.27.1Downloading requests-2.27.1-py2.py3-none-any.whl (63 kB)
Collecting sentry-sdk==1.5.6Downloading sentry_sdk-1.5.6-py2.py3-none-any.whl (144 kB)
Collecting shortuuid==1.0.8Downloading shortuuid-1.0.8-py3-none-any.whl (9.5 kB)
Collecting smmap==5.0.0Downloading smmap-5.0.0-py3-none-any.whl (24 kB)
Collecting termcolor==1.1.0Downloading termcolor-1.1.0.tar.gz (3.9 kB)
Collecting urllib3==1.26.8Downloading urllib3-1.26.8-py2.py3-none-any.whl (138 kB)
Collecting wandb==0.12.10Downloading wandb-0.12.10-py2.py3-none-any.whl (1.7 MB)
Collecting yaspin==2.1.0Downloading yaspin-2.1.0-py3-none-any.whl (18 kB)
Collecting zipp==3.7.0Downloading zipp-3.7.0-py3-none-any.whl (5.3 kB)
Requirement already satisfied: six>=1.4.0 in /home/ubuntu/miniconda3/envs/con_110/lib/python3.7/site-packages (from docker-pycreds==0.4.0->-r /home/ubuntu/GLC/condaenv.h1f9e76a.requirements.txt (line 3)) (1.16.0)
Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/ubuntu/miniconda3/envs/con_110/lib/python3.7/site-packages (from gitpython==3.1.27->-r /home/ubuntu/GLC/condaenv.h1f9e76a.requirements.txt (line 5)) (3.10.0.2)
Requirement already satisfied: certifi>=2017.4.17 in /home/ubuntu/miniconda3/envs/con_110/lib/python3.7/site-packages (from requests==2.27.1->-r /home/ubuntu/GLC/condaenv.h1f9e76a.requirements.txt (line 13)) (2022.9.24)
Requirement already satisfied: python-dateutil>=2.6.1 in /home/ubuntu/miniconda3/envs/con_110/lib/python3.7/site-packages (from wandb==0.12.10->-r /home/ubuntu/GLC/condaenv.h1f9e76a.requirements.txt (line 19)) (2.8.2)
Building wheels for collected packages: pathtools, promise, termcolorBuilding wheel for pathtools (setup.py): startedBuilding wheel for pathtools (setup.py): finished with status 'done'Created wheel for pathtools: filename=pathtools-0.1.2-py3-none-any.whl size=8806 sha256=a66ada93957cf7fc7b3ef5bffd7844b018a4a97eaca9289f2e292761489ee2d8Stored in directory: /home/ubuntu/.cache/pip/wheels/3e/31/09/fa59cef12cdcfecc627b3d24273699f390e71828921b2cbba2Building wheel for promise (setup.py): startedBuilding wheel for promise (setup.py): finished with status 'done'Created wheel for promise: filename=promise-2.3-py3-none-any.whl size=21503 sha256=884eb51f491d088c5fb1959e5be5f3ec41086ef58eac9c32cc737c5c83a45578Stored in directory: /home/ubuntu/.cache/pip/wheels/29/93/c6/762e359f8cb6a5b69c72235d798804cae523bbe41c2aa8333dBuilding wheel for termcolor (setup.py): startedBuilding wheel for termcolor (setup.py): finished with status 'done'Created wheel for termcolor: filename=termcolor-1.1.0-py3-none-any.whl size=4848 sha256=889e55b1d10f55c622c011af4442358d02ae5abd2629c38ed91bdaebd3dd542dStored in directory: /home/ubuntu/.cache/pip/wheels/3f/e3/ec/8a8336ff196023622fbcb36de0c5a5c218cbb24111d1d4c7f2
Successfully built pathtools promise termcolor
Installing collected packages: zipp, smmap, urllib3, termcolor, importlib-metadata, idna, gitdb, charset-normalizer, yaspin, shortuuid, sentry-sdk, requests, pyyaml, psutil, protobuf, promise, pathtools, gitpython, docker-pycreds, click, wandbAttempting uninstall: psutilFound existing installation: psutil 5.8.0Uninstalling psutil-5.8.0:Successfully uninstalled psutil-5.8.0
Successfully installed charset-normalizer-2.0.12 click-8.0.4 docker-pycreds-0.4.0 gitdb-4.0.9 gitpython-3.1.27 idna-3.3 importlib-metadata-4.11.1 pathtools-0.1.2 promise-2.3 protobuf-3.19.4 psutil-5.9.0 pyyaml-6.0 requests-2.27.1 sentry-sdk-1.5.6 shortuuid-1.0.8 smmap-5.0.0 termcolor-1.1.0 urllib3-1.26.8 wandb-0.12.10 yaspin-2.1.0 zipp-3.7.0done
#
# To activate this environment, use
#
#     $ conda activate con_110
#
# To deactivate an active environment, use
#
#     $ conda deactivate

这篇关于【Trick】conda指令安装yml文件中的python依赖的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/959447

相关文章

Zookeeper安装和配置说明

一、Zookeeper的搭建方式 Zookeeper安装方式有三种,单机模式和集群模式以及伪集群模式。 ■ 单机模式:Zookeeper只运行在一台服务器上,适合测试环境; ■ 伪集群模式:就是在一台物理机上运行多个Zookeeper 实例; ■ 集群模式:Zookeeper运行于一个集群上,适合生产环境,这个计算机集群被称为一个“集合体”(ensemble) Zookeeper通过复制来实现

这15个Vue指令,让你的项目开发爽到爆

1. V-Hotkey 仓库地址: github.com/Dafrok/v-ho… Demo: 戳这里 https://dafrok.github.io/v-hotkey 安装: npm install --save v-hotkey 这个指令可以给组件绑定一个或多个快捷键。你想要通过按下 Escape 键后隐藏某个组件,按住 Control 和回车键再显示它吗?小菜一碟: <template

CentOS7安装配置mysql5.7 tar免安装版

一、CentOS7.4系统自带mariadb # 查看系统自带的Mariadb[root@localhost~]# rpm -qa|grep mariadbmariadb-libs-5.5.44-2.el7.centos.x86_64# 卸载系统自带的Mariadb[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7

Centos7安装Mongodb4

1、下载源码包 curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.2.1.tgz 2、解压 放到 /usr/local/ 目录下 tar -zxvf mongodb-linux-x86_64-rhel70-4.2.1.tgzmv mongodb-linux-x86_64-rhel70-4.2.1/

python: 多模块(.py)中全局变量的导入

文章目录 global关键字可变类型和不可变类型数据的内存地址单模块(单个py文件)的全局变量示例总结 多模块(多个py文件)的全局变量from x import x导入全局变量示例 import x导入全局变量示例 总结 global关键字 global 的作用范围是模块(.py)级别: 当你在一个模块(文件)中使用 global 声明变量时,这个变量只在该模块的全局命名空

每天认识几个maven依赖(ActiveMQ+activemq-jaxb+activesoap+activespace+adarwin)

八、ActiveMQ 1、是什么? ActiveMQ 是一个开源的消息中间件(Message Broker),由 Apache 软件基金会开发和维护。它实现了 Java 消息服务(Java Message Service, JMS)规范,并支持多种消息传递协议,包括 AMQP、MQTT 和 OpenWire 等。 2、有什么用? 可靠性:ActiveMQ 提供了消息持久性和事务支持,确保消

Centos7安装JDK1.8保姆版

工欲善其事,必先利其器。这句话同样适用于学习Java编程。在开始Java的学习旅程之前,我们必须首先配置好适合的开发环境。 通过事先准备好这些工具和配置,我们可以避免在学习过程中遇到因环境问题导致的代码异常或错误。一个稳定、高效的开发环境能够让我们更加专注于代码的学习和编写,提升学习效率,减少不必要的困扰和挫折感。因此,在学习Java之初,投入一些时间和精力来配置好开发环境是非常值得的。这将为我

【Python编程】Linux创建虚拟环境并配置与notebook相连接

1.创建 使用 venv 创建虚拟环境。例如,在当前目录下创建一个名为 myenv 的虚拟环境: python3 -m venv myenv 2.激活 激活虚拟环境使其成为当前终端会话的活动环境。运行: source myenv/bin/activate 3.与notebook连接 在虚拟环境中,使用 pip 安装 Jupyter 和 ipykernel: pip instal

【机器学习】高斯过程的基本概念和应用领域以及在python中的实例

引言 高斯过程(Gaussian Process,简称GP)是一种概率模型,用于描述一组随机变量的联合概率分布,其中任何一个有限维度的子集都具有高斯分布 文章目录 引言一、高斯过程1.1 基本定义1.1.1 随机过程1.1.2 高斯分布 1.2 高斯过程的特性1.2.1 联合高斯性1.2.2 均值函数1.2.3 协方差函数(或核函数) 1.3 核函数1.4 高斯过程回归(Gauss

安装nodejs环境

本文介绍了如何通过nvm(NodeVersionManager)安装和管理Node.js及npm的不同版本,包括下载安装脚本、检查版本并安装特定版本的方法。 1、安装nvm curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash 2、查看nvm版本 nvm --version 3、安装