如何使用pip从本地缓存安装? [英] How do I install from a local cache with pip?

查看:346
本文介绍了如何使用pip从本地缓存安装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在不同的 virtualenv 环境中安装了许多相同的软件包.有没有一种方法可以下载一次软件包,然后从本地缓存中安装 pip ?

I install a lot of the same packages in different virtualenv environments. Is there a way that I can download a package once and then have pip install from a local cache?

这将减少下载带宽和时间.

This would reduce download bandwidth and time.

推荐答案

更新后的答案2015年11月19日

根据 Pip文档:

从v6.0开始,pip默认提供一个on缓存,其功能类似于Web浏览器.在默认情况下,当缓存处于打开状态并且被设计为默认情况下,做正确的事时,您可以禁用缓存并始终使用--no-cache-dir选项访问PyPI.

Starting with v6.0, pip provides an on by default cache which functions similarly to that of a web browser. While the cache is on by default and is designed do the right thing by default you can disable the cache and always access PyPI by utilizing the --no-cache-dir option.

因此,更新的答案是,如果要下载缓存,则仅使用pip及其默认值.

Therefore, the updated answer is to just use pip with its defaults if you want a download cache.

pip新闻 ,版本0.1.4:

From the pip news, version 0.1.4:

增加了对环境变量$ PIP_DOWNLOAD_CACHE的支持,该变量将缓存程序包下载,因此以后的安装将不需要大量下载.仍然需要网络访问权限,但是使用此功能时只能避免一些下载.

Added support for an environmental variable $PIP_DOWNLOAD_CACHE which will cache package downloads, so future installations won’t require large downloads. Network access is still required, but just some downloads will be avoided when using this.

要利用这一点,我在~/.bash_profile中添加了以下内容:

To take advantage of this, I've added the following to my ~/.bash_profile:

export PIP_DOWNLOAD_CACHE=$HOME/.pip_download_cache

或者,如果您使用的是Mac:

or, if you are on a Mac:

export PIP_DOWNLOAD_CACHE=$HOME/Library/Caches/pip-downloads

注释

  1. 如果检测到软件包的较新版本,则将其下载并添加到PIP_DOWNLOAD_CACHE目录中.例如,我现在有很多Django软件包.
  2. 这并不能消除对网络访问的需求,如点子新闻,因此这不是在飞机上创建新的virtualenvs的答案,但这仍然很棒.
  1. If a newer version of a package is detected, it will be downloaded and added to the PIP_DOWNLOAD_CACHE directory. For instance, I now have quite a few Django packages.
  2. This doesn't remove the need for network access, as stated in the pip news, so it's not the answer for creating new virtualenvs on the airplane, but it's still great.

这篇关于如何使用pip从本地缓存安装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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