Using a pip requirements file in a conda yml file throws AttributeError: 'FileNotFoundError'

Using a pip requirements file in a conda yml file throws 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 subprocess output:

Pip subprocess error: ERROR: Exception:

<... pip 中的错误回溯>

AttributeError: 'FileNotFoundError' object has no attribute 'read'

failed

CondaEnvException: Pip failed

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 has changed its behavior to be more strict with respect to file: URI syntax. As pointed out by a PyPA member and Pip developer, the syntax file:requirements.txt is not a valid URI according to the RFC8089 specification.

相反,必须完全放弃 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