pip hash
命令用于计算本地包归档的 sha
值
语法格式
pip hash [options] <file> ...
该命令可以和 requirements.txt
文件中的 --hash
一起使用以进行可重复安装
简介
pip hash
命令可以很方便的获取散列摘要以便与散列检查模式一起使用,尤其适用于具有多个归档的包
pip install --require-hashes ...
安装一个包时产生的错误消息中会包含一个哈希值,但如果存在多个存档( 如源和二进制存档 ) ,则需要手动下载并计算其它存档的哈希值
否则,在命令 pip install
中传递一组不同的选项 ( 如 --no-binary
) 时,可能会发生虚假的哈希不匹配
选项
-
-a, --algorithm <algorithm>
摘要算法,可选的值有 sha256, sha384, sha512
范例
-
下载
requests
$ pip download requests Looking in indexes: https://pypi.douban.com/simple Collecting requests Downloading https://pypi.doubanio.com/packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl (91kB) 100% |████████████████████████████████| 92kB 3.3MB/s Saved ./requests-2.19.1-py2.py3-none-any.whl Collecting idna<2.8,>=2.5 (from requests) Downloading https://pypi.doubanio.com/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl (58kB) 100% |████████████████████████████████| 61kB 8.0MB/s Saved ./idna-2.7-py2.py3-none-any.whl Collecting urllib3<1.24,>=1.21.1 (from requests) Downloading https://pypi.doubanio.com/packages/bd/c9/6fdd990019071a4a32a5e7cb78a1d92c53851ef4f56f62a3486e6a7d8ffb/urllib3-1.23-py2.py3-none-any.whl (133kB) 100% |████████████████████████████████| 143kB 7.5MB/s Saved ./urllib3-1.23-py2.py3-none-any.whl Collecting chardet<3.1.0,>=3.0.2 (from requests) Using cached https://pypi.doubanio.com/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl Saved ./chardet-3.0.4-py2.py3-none-any.whl Collecting certifi>=2017.4.17 (from requests) Downloading https://pypi.doubanio.com/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl (150kB) 100% |████████████████████████████████| 153kB 4.6MB/s Saved ./certifi-2018.4.16-py2.py3-none-any.whl Successfully downloaded requests idna urllib3 chardet certifi
仔细查看命令的结果,可以看到
Saved ./requests-2.19.1-py2.py3-none-any.whl
表示下载后的路径为
./requests-2.19.1-py2.py3-none-any.whl
-
计算已下载的
requests
的哈希值$ pip hash requests-2.19.1-py2.py3-none-any.whl requests-2.19.1-py2.py3-none-any.whl: --hash=sha256:63b52e3c866428a224f97cab011de738c36aec0185aa91cfacd418b5d58911d1
目前尚无回复