37
votes

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
8
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
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
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
check my answer in this page .. - Ahmad Tarbeya

8 Answers

49
votes

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

8
votes

--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.

7
votes

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
5
votes

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
2
votes

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

0
votes

I got the error during installing panads

You need to remove the cache and reinstall .

pip install --no-cache-dir flask
0
votes

The solution may be made apparent by simply verifying the specified package's published hash with your calculated hash of the downloaded file.

If they match - then the pip install might have corrupted the download. If they don't match - then either the hash was not correctly published when the package was published - or - whomever tampered with the download file missed updating the md5 hash.

Be thankful that pip has proper download hygiene. A vast majority of computer users never compare hashes of the software they download and install.

0
votes

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.