Once in a while, a Python package gets corrupted on your machine and you need to force pip to reinstall it. As of pip 10.0, you can run the following:
pip install --force-reinstall <corrupted package>This will force pip to re-install <corrupted package> and all its dependencies.
If you want to re-download the packages instead of using the files from your pip cache, add the --no-cache-dir flag:
pip install --force-reinstall --no-cache-dir <corrupted package>If you want to upgrade the package, you can run this instead:
pip install --upgrade <corrupted package>The --upgrade flag will not mess with the dependencies of <corrupted package> unless you add the --force-reinstall flag.
If, for some reason, you want to re-install <corrupted package> and all its dependencies without first removing the current versions, you can run:
pip install --ignore-installed <corrupted package>By the way, if you’re using a pip version that is less than 10.0, it’s time to update pip:
pip install --upgrade pip