前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Python 常见问题 - pip install 指定 poetry 导出的 requirements.txt,报错 ERROR: In --require-hashes mode, all req

Python 常见问题 - pip install 指定 poetry 导出的 requirements.txt,报错 ERROR: In --require-hashes mode, all req

作者头像
小菠萝测试笔记
发布2021-10-12 16:17:37
1.7K0
发布2021-10-12 16:17:37
举报

背景

  • Python 3.9
  • pip 21.2.3
  • poetry 1.1.8
执行了命令,导出 requirements.txt
代码语言:javascript
复制
 poetry export  -f requirements.txt --output requirements.txt     
查看 requirements.txt

每个库都有 hash 加密字段

执行 pip install 命令
代码语言:javascript
复制
pip3 install --no-cache-dir --upgrade  -r requirements.txt  

就报错了

代码语言:javascript
复制
#8 28.40 Collecting websockets==10.0
#8 28.51   Downloading websockets-10.0-cp39-cp39-manylinux2010_x86_64.whl (107 kB)
#8 29.38 Collecting cffi>=1.1
#8 29.38 ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
#8 29.38     cffi>=1.1 from https://files.pythonhosted.org/packages/be/2a/6d266eea47dbb2d872bbd1b8954a2d167668481ff34ebb70ffdd1113eeab/cffi-1.14.6-cp39-cp39-manylinux1_x86_64.whl#sha256=f3ebe6e73c319340830a9b2825d32eb6d8475c1dac020b4f0aa774ee3b898d1c (from bcrypt==3.2.0->-r /code/requirements.txt (line 19))
------
executor failed running [/bin/sh -c pip install --no-cache-dir --upgrade -r /code/requirements.txt]: exit code: 1

排查思路

解决方案

poetry export命令中传递此标志 --without-hashes

代码语言:javascript
复制
poetry export --without-hashes -f requirements.txt --output requirements.txt

我使用的是这个办法,实践过的确可以,适用于使用 poetry 的小伙伴

后面的这几种场景还没试过

场景一

停止使用 pip --contstraints标志传递带有固定散列的包

场景二

如果直接使用 pip 则将其固定到 20.3 之前的版本

代码语言:javascript
复制
python -m pip install --upgrade pip==20.2.4
场景三

如果正在使用其他 virtualenv 依赖于 pip 的东西,请确保将其版本固定

代码语言:javascript
复制
python -m pip install --upgrade virtualenv==20.0.26

或者使用环境变量 VIRTUALENV_PIP=20.2.4

本文参与?腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021-10-08 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客?前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与?腾讯云自媒体同步曝光计划? ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 背景
    • 执行了命令,导出 requirements.txt
      • 查看 requirements.txt
        • 执行 pip install 命令
        • 排查思路
        • 解决方案
          • 场景一
            • 场景二
              • 场景三
              领券
              问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
              http://www.vxiaotou.com