Python packages hash not matching whilst installing using pip
Question:
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
Answers:
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
--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.
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
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
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.
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 cache:
pip install --no-cache-dir the_library_name
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>
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:
- installl an older pkg version =,
pip install flask==0.0.9
- wait new pkg release
flask==1.0.1
or cache expiration.
In case you got this error while using pipenv try
$ pipenv --clear
$ pipenv lock
$ pipenv install
I have tried to clear pip cache with -m pip cache purge
and using the --no-cache-dir
argument but it was not helping.
In my case it was VPN being active during the attempts to install the package. As soon as I have turned it off everything worked as expected.
This worked for me!
pip install --no-cache-dir flask --user
The solution that worked for me:
$ source .venv/Scripts/activate
$ python -m pip install --upgrade pip
$ python -m pip install <package> --no-cache-dir
If it does not work for some packages try to do this before the previous steps: https://stackoverflow.com/a/69668918/17596747
Then do the first 3 steps again.
UPD. Also maybe the problem is in VPN. Try to turn off/turn on VPN and see if this helps.
--no-cache-dir
and cleaning the cash didn’t work.
I installed .whl
package through link in error text and installed it with pip install like: pip install Werkzeug-0.11.11-py2.py3-none-any.whl
(in the same folder where it is downloaded).
After that everything worked with same pip install
command that returned a error.
Try:
rm -rf "$(pip cache dir)"
And if you’re using conda:
conda clean --all
If your pip is version 3 then you should try:
pip3 install <package name>
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
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
--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.
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
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
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.
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 cache:
pip install --no-cache-dir the_library_name
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>
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:
- installl an older pkg version =,
pip install flask==0.0.9
- wait new pkg release
flask==1.0.1
or cache expiration.
In case you got this error while using pipenv try
$ pipenv --clear
$ pipenv lock
$ pipenv install
I have tried to clear pip cache with -m pip cache purge
and using the --no-cache-dir
argument but it was not helping.
In my case it was VPN being active during the attempts to install the package. As soon as I have turned it off everything worked as expected.
This worked for me!
pip install --no-cache-dir flask --user
The solution that worked for me:
$ source .venv/Scripts/activate
$ python -m pip install --upgrade pip
$ python -m pip install <package> --no-cache-dir
If it does not work for some packages try to do this before the previous steps: https://stackoverflow.com/a/69668918/17596747
Then do the first 3 steps again.
UPD. Also maybe the problem is in VPN. Try to turn off/turn on VPN and see if this helps.
--no-cache-dir
and cleaning the cash didn’t work.
I installed .whl
package through link in error text and installed it with pip install like: pip install Werkzeug-0.11.11-py2.py3-none-any.whl
(in the same folder where it is downloaded).
After that everything worked with same pip install
command that returned a error.
Try:
rm -rf "$(pip cache dir)"
And if you’re using conda:
conda clean --all
If your pip is version 3 then you should try:
pip3 install <package name>