python - Conda 在使用 channel 时无法解析 requirements.yml

标签 python anaconda conda miniconda

我正在尝试使用 requirements.yml 创建带有 miniconda 的环境从另一个 conda 环境生成的文件。我在处理来自 channel 的包裹时遇到了麻烦。

在机器上 requirements.yml使用以下命令从现有环境生成:

(myenv)$ conda env export > requirements.yml

requirements.yml 的内容文件是(清理版本号后):

name: myenv
channels: !!python/tuple
- !!python/unicode
 'defaults'
dependencies:
- pytest
- conda-forge::pytest-xdist
- pytest-cov
- numpy
- scipy
- pymongo
- auto::pycallgraph
- flask
- conda-forge::flask-restful
- conda-forge::flask-httpauth
- blaze::flask-mongoengine
- hugo::flask-security
- flask-wtf
- wtforms
- conda-forge::mongoengine
- pip:
 - descartes
prefix: .miniconda2/envs/myenv

上面的包已经通过指定 channel “手动”安装,例如,

$(myenv) conda install -c conda-forge pytest-xdist

正在转移 requirements.yml到另一台机器(相同架构,linux-64),conda 无法创建新环境:

$ conda env create --file requirements.yml

Fetching package metadata .......
Solving package specifications: .
Error: Packages missing in current linux-64 channels: 
  - conda-forge::pytest-xdist
  - auto::pycallgraph
  - conda-forge::flask-restful
  - conda-forge::flask-httpauth
  - blaze::flask-mongoengine
  - hugo::flask-security
  - conda-forge::mongoengine

conda 好像无法解析语法<channel>::<package name> .

使用的系统:docker image continuumio/miniconda。

您是否有任何想法如何从规范文件很好地创建一个新环境(例如,对持续集成有用)?

最佳答案

解决方案一:

将 conda 更新到版本 4.2.12(在我的例子中是 4.1)

conda update conda

然后通过加载需求文件创建环境

conda env create -f requirements.yml

解决方案 2:

在文件的 channels 部分添加 channel 名称,并在包列表中删除 channel 名称:

name: myenv
channels: !!python/tuple
- !!python/unicode
  'defaults'
- !!python/unicode
  'auto'
- !!python/unicode
  'conda-forge'
- !!python/unicode
  'blaze'
- !!python/unicode
  'hugo'
dependencies:
- pytest
- pytest-xdist
- pytest-cov
- numpy
- scipy
- pymongo
- pycallgraph
- flask
- flask-restful
- flask-httpauth
- flask-mongoengine
- flask-security
- flask-wtf
- wtforms
- mongoengine
- pip:
 - descartes
prefix: .miniconda2/envs/myenv

关于python - Conda 在使用 channel 时无法解析 requirements.yml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40619682/

相关文章:

python - 如何使用 Featuretools 按列值从单个数据框中的多列创建特征?

python - 如何在我的 docker 容器中运行 pycharm?

python - conda info 中声明的 python 版本与 conda list 中给出的 python 版本有什么区别?

python - Conda 中的语法错误

python - Django - 服务用户上传的图片

python - SQLAlchemy 选择存在限制

python - 在 Python 中,如何通过键列连接两个数组?

python - 无法在Anaconda上的虚拟环境中安装Spyder

path - Ipython笔记本,如何设置正确的内核路径

python - Huggingface 变形金刚 Conda 安装问题