python - 如何在不创建新环境的情况下从一个文件在 conda 中安装多个包?

标签 python package installation anaconda conda

我从我当前环境丢失的包的 yml 文件中获取了这些。我如何在我当前的环境中安装它们?

channels:
  - defaults
dependencies:
  - appdirs=1.4.3=py36h28b3542_0
  - asn1crypto=0.24.0=py36_0
  - attrs=18.2.0=py36h28b3542_0
  - blas=1.0=mkl
  - cffi=1.11.5=py36h6174b99_1
  - constantly=15.1.0=py36h28b3542_0
  - cryptography=2.3.1=py36hdbc3d79_0
  - freetype=2.9.1=hb4e5f40_0
  - html5lib=1.0.1=py36_0
  - idna=2.7=py36_0
  - incremental=17.5.0=py36_0
  - intel-openmp=2019.0=118
  - libgfortran=3.0.1=h93005f0_2
  - libxml2=2.9.4=0
  - libxslt=1.1.29=hc208041_6
  - lxml=4.1.1=py36h6c891f4_0
  - mkl=2019.0=118
  - mkl_fft=1.0.6=py36hb8a8100_0
  - mkl_random=1.0.1=py36h5d10147_1
  - numpy=1.15.3=py36h6a91979_0
  - numpy-base=1.15.3=py36h8a80b8c_0
  - pyasn1=0.4.4=py36h28b3542_0
  - pyasn1-modules=0.2.2=py36_0
  - pycparser=2.19=py36_0
  - pyopenssl=18.0.0=py36_0
  - service_identity=17.0.0=py36h28b3542_0
  - twisted=17.5.0=py36_0
  - zope=1.0=py36_1
  - zope.interface=4.5.0=py36h1de35cc_0
  - pip:
    - absl-py==0.2.2
    - ete3==3.1.1
    - grpcio==1.12.1

最佳答案

Conda 环境更新

如果您有 YAML 文件,那么将其应用于给定环境的最有效方法是使用 conda env update:

conda env update --file environment.yml

⚠️ Warning: The conda env commands don't prompt you to review and approve the transactions - it simply executes the changes. Be sure to carefully review the YAML file to ensure all of the changes are desired.

conda 安装

Conda 接受的 conda install --file 格式与 conda list --export 的输出匹配。它不是 YAML,而是一个简单的文本文件,每行一个包,类似于 pip freeze 生成的文件,除了单个等号('=' 而不是 ==)。

conda list --export

appdirs=1.4.3=py36h28b3542_0
asn1crypto=0.24.0=py36_0
...
zope=1.0=py36_1
zope.interface=4.5.0=py36h1de35cc_0

请注意,构建不是必需的,例如,以下内容也可以工作,并且实际上可能在跨体系结构中更具可移植性

appdirs=1.4.3
asn1crypto=0.24.0
...
zope=1.0
zope.interface=4.5.0

不幸的是,conda install 不支持 PyPI 包;您必须在激活的环境中通过 pip install 单独安装它们。

关于python - 如何在不创建新环境的情况下从一个文件在 conda 中安装多个包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52998670/

相关文章:

android - 构建期间找不到 Github 包

r - ggplotify 包中的函数 as.ggplot() 出现奇怪的错误

wix - 什么是最好的 MSI 生成安装工具?

python - Vim:如何安装 UltiSnips 插件?

python - 如何解释 vowpal wabbit --rank 模型的 --audit 和 --invert_hash 输出?

python - 在列中按关键字删除行,然后删除所有列并在python中另存为文本

meteor - 我如何在 Meteor 中降级一个包?

android:安装应用程序无需用户干预

python - 为什么我的 Sprite 不动

python - Django fixtures 和 OneToOneField