如何更新包哈希?Win10下Anaconda安装kwant遇哈希不匹配问题求助
Hey there, let's walk through solving this hash mismatch error you're getting when installing Kwant via pip. I've dealt with similar issues on Windows with Anaconda, so here are the practical steps to get it working:
First, confirm you're using the right pip
Make sure you're using the pip bundled with your Anaconda environment, not the system-wide pip. Activate your Anaconda environment first (if you're using the base env, runconda activate base), then verify with:pip --versionThe output should show a path inside your Anaconda installation folder—this ensures you're installing into the correct environment with the pre-installed scipy and numpy.
Clear pip's cache and install the local .whl directly
Hash mismatches often stem from pip having a cached package version that doesn't match. Clear the cache first:pip cache purgeThen install the exact .whl file you downloaded, specifying its full or relative path. For example, if it's in your Downloads folder:
pip install C:\Users\YourName\Downloads\kwant-1.3.2-cp36-cp36m-win_amd64.whlInstalling directly from the local file skips PyPI's hash check entirely, which eliminates the mismatch error.
Verify compatible scipy/numpy versions
Kwant 1.3.2 has specific dependency requirements for numpy and scipy. Check your current versions with:conda list scipy numpyIf your versions are too old or new, adjust them to compatible ones (for Python 3.6, numpy >=1.13 and scipy >=0.19 work well). Use conda to update/downgrade:
conda install numpy=1.16 scipy=1.2This ensures the dependencies align with what Kwant expects.
If all else fails, disable cache for the install
If you still run into issues, try installing with the--no-cache-dirflag to force pip to ignore any cached files:pip install ./kwant-1.3.2-cp36-cp36m-win_amd64.whl --no-cache-dirThis is a quick fix for persistent cache-related hash problems.
Just remember to run all these commands with your Anaconda environment activated—this avoids conflicts with system packages.
内容的提问来源于stack exchange,提问作者aminoffline

