在Conda YML文件中使用pip要求文件会引发AttributeError:'FileNotFoundError' [英] Using a pip requirements file in a conda yml file throws AttributeError: 'FileNotFoundError'

查看:33
本文介绍了在Conda YML文件中使用pip要求文件会引发AttributeError:'FileNotFoundError'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个requirements.txt

numpy

和包含

environment.yml
# run via: conda env create --file environment.yml
---
name: test
dependencies:
  - python>=3
  - pip
  - pip:
      - -r file:requirements.txt

当我随后运行conda env create --file environment.yml时,我收到

Pip子进程输出:

Pip子进程错误: 错误:异常:

<;.PIP>;中的错误回溯

AttributeError:"FileNotFoundError"对象没有属性""Read""

失败

CondaEnvException:PIP失败

调用pip的方式也很奇怪,就像错误发生前报告的那样:

['$HOME/.conda/envs/test/bin/python', '-m', 'pip', 'install', '-U', '-r', '$HOME/test/condaenv.8d3003nm.requirements.txt']

(我将我的主路径替换为$HOME) 注意requirements.txt的奇怪扩展。

有什么想法吗?

推荐答案

21.2.1中对管道行为的更改

A recent change in the Pip code已将其行为更改为在file:URI语法方面更加严格。As pointed out由Pypa成员和Pip开发人员根据the RFC8089 specification,语法file:requirements.txt不是有效的URI。

相反,必须完全放弃file:方案:

name: test
dependencies:
  - python>=3
  - pip
  - pip:
    - -r requirements.txt

或提供有效的URI,即使用绝对路径(或本地文件服务器):

name: test
dependencies:
  - python>=3
  - pip
  - pip:
    - -r file:/full/path/to/requirements.txt
    # - -r file:///full/path/to/requirements.txt # alternate syntax

这篇关于在Conda YML文件中使用pip要求文件会引发AttributeError:&#39;FileNotFoundError&#39;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆