【虚拟环境下的.yml文件/requirement.txt文件的生成与重新加载】 您所在的位置:网站首页 把mdb改为txt 【虚拟环境下的.yml文件/requirement.txt文件的生成与重新加载】

【虚拟环境下的.yml文件/requirement.txt文件的生成与重新加载】

2024-07-14 05:31| 来源: 网络整理| 查看: 265

【虚拟环境下的.yml文件/requirement.txt文件的生成与重新加载】 文前白话pip 方式下生成requirements.txt环境包文件① requirements.txt文件的生成②安照 requirements.txt文件在新的电脑端安装环境包 conda 方式下的yml文件① yml文件的生成② 安照.yml文件加载环境

文前白话

进行项目开发的过程中,如果需要将自己配置好的虚拟环境在另外的电脑端进行转移,或者分享运行的环境,可以将环境依赖写入文件中。

pip 方式下生成requirements.txt环境包文件

requirements.txt文件包含项目所需要的所有安装包,如下图: 在这里插入图片描述

说明:

使用requirements.txt文件安装环境包,需要自己提前重新创建好一个新的环境,指定python的版本,环境的名称等等,而使用.yml文件则不用,因为.yml文件中会包含复制环境安装包时候对应的环境名,写在文件中了。 另外,开源的项目中,指定的安装环境文件还会区分cpu和gpu两种,主要与电脑硬件关联。

① requirements.txt文件的生成

步骤: 激活进入需要打包依赖的虚拟环境中: 执行代码:

pip freeze >requirements_self_named.txt

生成的文件可以自己命名 将requirements.txt -> 文件名.txt 在这里插入图片描述 这里如果要分享环境,只需分享requirements_self_named.txt文件。

②安照 requirements.txt文件在新的电脑端安装环境包

在新建立的空白环境中,cd 进入requirements_self_named.txt文件所在目录下,执行命令:

pip install -r requirements_self_named.txt

就可以创建上述或者别人指定的安装包。

conda 方式下的yml文件

在这里插入图片描述

对比可以发现,yml文件安装方式更加方便,通过conda命令,可以直接指定环境名称、python版本以及pip所需要的安装包。

① yml文件的生成

同上述步骤,激活进入目标环境中,执行命令:

conda env export > conda-self-named-gpu.yml

如: 在这里插入图片描述 通过yml文件可以创建或者分享指定项目所需环境。

② 安照.yml文件加载环境

直接在 conda 的base 环境下,cd 进入.yml文件所在的路径后,执行:

conda env create -f 文件名.yml

附: yolov4-deepsort-gpu 的.yml 文件(亲测可运行)

Cudatoolkit=10.1.243 cudnn=7.6.5

name: yolov4-deepsort channels:

defaults dependencies:_libgcc_mutex=0.1=main_openmp_mutex=4.5=1_gnublas=1.0=mklbrotli=1.0.9=he6710b0_2bzip2=1.0.8=h7b6447c_0ca-certificates=2021.7.5=h06a4308_1cairo=1.14.12=h8948797_3certifi=2021.5.30=py37h06a4308_0cudatoolkit=10.1.243=h6bb024c_0cudnn=7.6.5=cuda10.1_0cycler=0.10.0=py37_0dbus=1.13.18=hb2f20db_0expat=2.4.1=h2531618_2ffmpeg=4.0=hcdf2ecd_0fontconfig=2.13.1=h6c09931_0fonttools=4.25.0=pyhd3eb1b0_0freeglut=3.0.0=hf484d3e_5freetype=2.10.4=h5ab3b9f_0glib=2.63.1=h5a9c865_0graphite2=1.3.14=h23475e2_0gst-plugins-base=1.14.0=hbbd80ab_1gstreamer=1.14.0=hb453b48_1harfbuzz=1.8.8=hffaf4a1_0hdf5=1.10.2=hba1933b_1icu=58.2=he6710b0_3intel-openmp=2021.3.0=h06a4308_3350jasper=2.0.14=h07fcdf6_1jpeg=9b=h024ee3a_2kiwisolver=1.3.1=py37h2531618_0lcms2=2.12=h3be6417_0libedit=3.1.20210714=h7f8727e_0libffi=3.2.1=hf484d3e_1007libgcc-ng=9.3.0=h5101ec6_17libgfortran-ng=7.5.0=ha8ba4b0_17libgfortran4=7.5.0=ha8ba4b0_17libglu=9.0.0=hf484d3e_1libgomp=9.3.0=h5101ec6_17libopencv=3.4.2=hb342d67_1libopus=1.3.1=h7b6447c_0libpng=1.6.37=hbc83047_0libstdcxx-ng=9.3.0=hd4cf53a_17libtiff=4.2.0=h85742a9_0libuuid=1.0.3=h1bed415_2libvpx=1.7.0=h439df22_0libwebp-base=1.2.0=h27cfd23_0libxcb=1.14=h7b6447c_0libxml2=2.9.12=h03d6c58_0lz4-c=1.9.3=h295c915_1matplotlib=3.4.2=py37h06a4308_0matplotlib-base=3.4.2=py37hab158f2_0mkl=2021.3.0=h06a4308_520mkl-service=2.4.0=py37h7f8727e_0mkl_fft=1.3.0=py37h42c9631_2mkl_random=1.2.2=py37h51133e4_0munkres=1.1.4=py_0ncurses=6.2=he6710b0_1olefile=0.46=py37_0opencv=3.4.2=py37h6fd60c2_1openjpeg=2.4.0=h3ad879b_0openssl=1.0.2u=h7b6447c_0pcre=8.45=h295c915_0pillow=8.3.1=py37h2c7a002_0pip=21.2.2=py37h06a4308_0pixman=0.40.0=h7b6447c_0py-opencv=3.4.2=py37hb342d67_1pyparsing=2.4.7=pyhd3eb1b0_0pyqt=5.9.2=py37h05f1152_2python=3.7.0=h6e4f718_3python-dateutil=2.8.2=pyhd3eb1b0_0qt=5.9.6=h8703b6f_2readline=7.0=h7b6447c_5setuptools=52.0.0=py37h06a4308_0sip=4.19.8=py37hf484d3e_0six=1.16.0=pyhd3eb1b0_0sqlite=3.33.0=h62c20be_0tk=8.6.10=hbc83047_0tornado=6.1=py37h27cfd23_0wheel=0.37.0=pyhd3eb1b0_0xz=5.2.5=h7b6447c_0zlib=1.2.11=h7b6447c_3zstd=1.4.9=haebb681_0pip: absl-py==0.13.0astunparse==1.6.3cachetools==4.2.2charset-normalizer==2.0.4click==8.0.1easydict==1.9flask==2.0.1gast==0.3.3google-auth==1.35.0google-auth-oauthlib==0.4.5google-pasta==0.2.0grpcio==1.39.0h5py==2.10.0idna==3.2importlib-metadata==4.8.0itsdangerous==2.0.1jinja2==3.0.1keras-preprocessing==1.1.2lxml==4.6.3markdown==3.3.4markupsafe==2.0.1numpy==1.18.5oauthlib==3.1.1opencv-python==4.1.1.26opt-einsum==3.3.0protobuf==3.17.3pyasn1==0.4.8pyasn1-modules==0.2.8requests==2.26.0requests-oauthlib==1.3.0rsa==4.7.2scipy==1.4.1tensorboard==2.2.2tensorboard-plugin-wit==1.8.0tensorflow-gpu==2.3.0rc0termcolor==1.1.0tf-estimator-nightly==2.3.0.dev2020062301tqdm==4.62.2typing-extensions==3.10.0.0urllib3==1.26.6werkzeug==2.0.1wrapt==1.12.1zipp==3.5.0


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有