本文介绍了错误:这些程序包不匹配需求文件中的哈希值.在更新Django时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Django 2.2.7,现在我想安装Django 3.0.2.我读到我需要运行命令 pip install -U Django 来更新它,但是当我尝试它时会显示此错误消息

I have Django 2.2.7 and now I want to install Django 3.0.2. I read that I need to run the command pip install -U Django to update it, but when I try it shows this error message

ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
    Django from https://files.pythonhosted.org/packages/55/d1/8ade70e65fa157e1903fe4078305ca53b6819ab212d9fbbe5755afc8ea2e/Django-3.0.2-py3-none-any.whl#sha256=4f2c913303be4f874015993420bf0bd8fd2097a9c88e6b49c6a92f9bdd3fb13a:
        Expected sha256 4f2c913303be4f874015993420bf0bd8fd2097a9c88e6b49c6a92f9bdd3fb13a
             Got        f97dfd0d593c3c78e81ca2f4fd095a21cd0a30752e7b8754294bf1d42541a218

我该怎么办?

这是我的requeriments.txt

this is my requeriments.txt

argon2-cffi==19.2.0
asgiref==3.2.3
cffi==1.13.2
Django==3.0.2
django-environ==0.4.5
djangorestframework==3.11.0
Pillow==7.0.0
psycopg2-binary==2.8.4
pycparser==2.19
pytz==2019.3
six==1.14.0
sqlparse==0.3.0

推荐答案

这是pips集成检查机制,可自动检查下载的软件包的完整性.

This is pips integrated checking mechanism that is automatically checking the integrity of the downloaded package.

您可以检查自己(通过点击has列),从pypi加载的 whl 文件的sha256应该为

You can check yourself (by clicking view in the has column) that the sha256 of the whl file loaded from pypi should be

4f2c913303be4f874015993420bf0bd8fd2097a9c88e6b49c6a92f9bdd3fb13a

您的错误表明您有错

f97dfd0d593c3c78e81ca2f4fd095a21cd0a30752e7b8754294bf1d42541a218

出于安全原因, pip 并未为您安装软件包.我建议

So pip is (for security reasons) not installing the package for you. I would suggest to

  • 检查 pip 是否从系统上某个 tmp 目录中获取了 whl ,并且下载了错误的 whl 文件放在此处-如果是这样,请尝试将其删除
  • 检查是否可以安装其他软件包而没有问题
  • 尝试手动下载 whl 文件,然后检查 pip hash< whl文件> 的输出(如果它匹配 4f2c91330 ... sha),如果可以的话 pip install< whl文件>
  • Check if pip is taking the whl from some tmp directory on your system with an incorrectly downloaded whl file sitting there - If so, try deleting it
  • Check if you can install other packages without issues
  • Try to manually download the whl file and then check the output of pip hash <whl file> (if it matches the 4f2c91330... sha) and if you can do pip install <whl file>

这篇关于错误:这些程序包不匹配需求文件中的哈希值.在更新Django时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 13:31