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

查看:74
本文介绍了如何缓存下载的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

这能回答您的问题吗?

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

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