如何缓存下载的 PIP 包 [英] How to cache downloaded PIP packages

查看:20
本文介绍了如何缓存下载的 PIP 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何防止 PIP 重新下载以前下载的软件包?我正在测试 matplotlib 的安装,这是一个 11MB 的软件包,它依赖于几个特定于发行版的软件包.每次我运行 pip install matplotlib 时,它都会重新下载 matplotlib.我该如何阻止?

How do you prevent PIP from re-downloading previously downloaded packages? I'm testing the install of matplotlib, an 11MB package that depends on several distro-specific packages. Everytime I run pip install matplotlib, it re-downloads matplotlib. How do I stop this?

推荐答案

您可以使用特定的环境变量 PIP_DOWNLOAD_CACHE 并使其指向将存储包的目录.如果要再次安装它们,它们将从这个目录中取出.

You can use a specific environment variable PIP_DOWNLOAD_CACHE and make it point to a directory where your packages will be stored. If they are to be installed again, they will be taken from this directory.

PIP pip --download-cache 似乎还有一个附加选项,它应该做类似的事情,但我自己从未尝试过.对于您的示例,为避免每次都重新下载 matplotlib,您将执行以下操作:

There seems to be also an additional option for PIP pip --download-cache which ought to do something similar, but I have never tried it myself. For your example, to avoid re-downloading matplotlib every time, you would do the following:

pip install --download-cache /path/to/pip/cache matplotlib

这是否回答了您的问题?

Does that answer your question?

这篇关于如何缓存下载的 PIP 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆