使用pip安装时Python包哈希不匹配

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40183108/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 23:14:25  来源:igfitidea点击:

Python packages hash not matching whilst installing using pip

pythonpip

提问by Milla Tidy

I am using pip to install all my python packages but get error as shown in the trace below. What is the problem and how can I solve it?

我正在使用 pip 安装我所有的 python 包,但出现错误,如下面的跟踪所示。有什么问题,我该如何解决?

usr@comp:~$ pip install flask
    Collecting flask
      Using cached Flask-0.11.1-py2.py3-none-any.whl
    Collecting itsdangerous>=0.21 (from flask)
      Using cached itsdangerous-0.24.tar.gz
    Collecting click>=2.0 (from flask)
      Using cached click-6.6.tar.gz
    Collecting Werkzeug>=0.7 (from flask)
      Using cached Werkzeug-0.11.11-py2.py3-none-any.whl
    Requirement already satisfied (use --upgrade to upgrade): Jinja2>=2.4 in /usr/lib/python2.7/dist-packages (from flask)
    Requirement already satisfied (use --upgrade to upgrade): MarkupSafe in /usr/lib/python2.7/dist-packages (from Jinja2>=2.4->flask)
    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.
        Werkzeug>=0.7 from https://pypi.python.org/packages/a9/5e/41f791a3f380ec50f2c4c3ef1399d9ffce6b4fe9a7f305222f014cf4fe83/Werkzeug-0.11.11-py2.py3-none-any.whl#md5=c63a21eedce9504d223ed89358c4bdc9 (from flask):
        Expected md5 c63a21eedce9504d223ed89358c4bdc9
             Got        13a168aafcc43354b6c79ef44bb0dc71

回答by Milla Tidy

There is a similar problem (Why does pip fail with bad md5 hash for package?) from 2013 the solution that I tried that worked for me is this:

还有一个类似的问题(为什么PIP失败,坏MD5哈希包?)从2013年开始,我试过为我工作的解决方案是这样的:

sudo pip install --no-cache-dir flask

sudo pip install --no-cache-dir flask

given by attolee

由 attolee 提供

回答by rajava

--no-cache-dirdid not work for me in raspberry pi 4 at first.

--no-cache-dir起初在 raspberry pi 4 中对我不起作用。

Found that the problem was due to unexpected network change/failure during pip installation

发现问题是由于pip安装过程中意外的网络变化/失败

I had to download the broken .whlfile manually with wget

我不得不.whl手动下载损坏的文件wget

and install it like below: sudo pip install scipy-1.3.0-cp37-cp37m-linux_armv7l.whl

并像下面一样安装它: sudo pip install scipy-1.3.0-cp37-cp37m-linux_armv7l.whl

followed by sudo pip install --no-cache-dir keras

其次是 sudo pip install --no-cache-dir keras

Then it worked.

然后它起作用了。

回答by paul

You need to upgrade your pip into the newer version:

您需要将 pip 升级到较新的版本:

Using this command:

使用这个命令:

python -m pip install -upgrade pip

for Mac/Linux operating system and use

适用于 Mac/Linux 操作系统并使用

python -m pip install --upgrade tensorflow

for Windows to update your pip. Then run your command

用于 Windows 更新您的 pip。然后运行你的命令

 pip install flask

回答by Tono Kuriakose

I got the error during installing panads

我在安装 panads 时遇到错误

You need to remove the cache and reinstall .

您需要删除缓存并重新安装 .

pip install --no-cache-dir flask

回答by Jay

Looks like a cache problem, the cached package is different from REQUIREMENTS.

貌似是缓存问题,缓存的包和REQUIREMENTS.

Perhaps caused by last updates interruption.

可能是上次更新中断造成的。

I did this which fixed my problem:

我这样做解决了我的问题:

rm ~/.cache/pip -rf