49

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?

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
davidism
  • 110,080
  • 24
  • 357
  • 317
Milla Tidy
  • 1,209
  • 1
  • 9
  • 11
  • Are you using a requirements file? This error suggests that you're using pip's hash checking mode and may be trying to upgrade a package's version without upgrading the hash first. – jonafato Oct 21 '16 at 19:58
  • No I am not explicitly using a requirements file but pip is checking flaks' dependencies using its (flask) requirements file. How do I make the hash upgrades? – Milla Tidy Oct 21 '16 at 20:12
  • Thanks to your comment jonafato, I fount a question from 2013 that has a solution that worked for me. The solution is in the answer below – Milla Tidy Oct 21 '16 at 20:21
  • check my answer in [this page](http://stackoverflow.com/questions/38028170/installing-python-packages-have-issue-in-md5/40400414#40400414) .. – Ahmad Tarbeya Nov 03 '16 at 11:48

10 Answers10

61

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:

sudo pip install --no-cache-dir flask

given by attolee

anothernode
  • 4,587
  • 11
  • 40
  • 56
Milla Tidy
  • 1,209
  • 1
  • 9
  • 11
15

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

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

I had to download the broken .whl file manually with wget

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

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

Then it worked.

AdityaSrivast
  • 948
  • 1
  • 8
  • 14
rajava
  • 151
  • 1
  • 2
  • 1
    Using `--no-cache-dir` did not work for me. This did! But not sure what the real problem is though. Thanks for the instruction. – Abhi Jul 06 '19 at 14:27
  • 1
    This fixed my problem also for me on a Raspberry Zero! `sudo` shouldn't be necessary in general though. – iipr Jul 19 '19 at 08:09
11

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

Perhaps caused by last updates interruption.

I did this which fixed my problem:

rm ~/.cache/pip -rf
Jay
  • 508
  • 5
  • 13
9

The problem here is the Python package was updated with new hash value while pip was trying to install the Python package using the old hash value cached in pip cache directory. This cache needs to be purge before the pip install attempt. So the full solution is:

python -m pip cache purge
python -m pip install <package>
Sergey Shubin
  • 2,689
  • 4
  • 23
  • 29
hstsvn
  • 124
  • 1
  • 5
7

You need to upgrade your pip into the newer version:

Using this command:

python -m pip install -upgrade pip

for Mac/Linux operating system and use

python -m pip install --upgrade tensorflow

for Windows to update your pip. Then run your command

 pip install flask
NelsonGon
  • 12,469
  • 5
  • 25
  • 52
paul
  • 71
  • 1
  • 4
4

first, try to upgrade your pip then install the library

python -m pip install -upgrade pip

if it didn't work just try to install it without the cash

pip install --no-cache-dir the_library_name

1

I got the error during installing panads

You need to remove the cache and reinstall .

pip install --no-cache-dir flask
Tono Kuriakose
  • 461
  • 4
  • 13
1

I had a similar issue for a different module. It was caused by network failure. My fix was nothing complex but another attempt at installing it and it worked.

Michael J
  • 31
  • 1
  • 2
1

In case you got this error while using pipenv try

$ pipenv --clear
$ pipenv lock
$ pipenv install
Levon
  • 8,597
  • 4
  • 42
  • 39
0

maybe pipiserver(where you pip install from) upload a pkg for example flask-1.0.0.tar.gz, and rm is upload a new flask-1.0.0.tag.gz,if new pkg code has changed ,the hash must be different,there is two ways:

  1. installl an older pkg version =, pip install flask==0.0.9
  2. wait new pkg release flask==1.0.1 or cache expiration.
Saeed
  • 2,748
  • 5
  • 29
  • 46
Ginta
  • 111
  • 5