Where is pip cache folder

2019-01-10 22:35发布

Where is pip cache folder? I had error during install and now reinstall packages using cache files

Where is that directory? I want backup them for install in the future. is it possible ?

For example I have this one :

Using cached cssselect-0.9.1.tar.gz

I searched google for this directory but anything I saw, is learn to how install from a folder, I want to find default cache directory.

And another question, these cache files will stay in that directory or will remove soon ??

标签: python pip
3条回答
We Are One
2楼-- · 2019-01-10 22:50

Because this question ranks, and the accepted answer doesn't quite match the question title:

The default location for the cache directory depends on the Operating System:

Unix

~/.cache/pip and it respects the XDG_CACHE_HOME directory.

macOS

~/Library/Caches/pip.

Windows

<CSIDL_LOCAL_APPDATA>\pip\Cache

Wheel Cache

Pip will read from the subdirectory wheels within the pip cache directory and use any packages found there. [snip]

https://pip.pypa.io/en/latest/reference/pip_install/#caching

The location of the cache directory can be changed via the command line option --cache-dir.

查看更多
Juvenile、少年°
3楼-- · 2019-01-10 23:01

Pythonic and cross-platform way:

from pip.utils.appdirs import user_cache_dir  # before pip v.10
from pip._internal.utils.appdirs import user_cache_dir  # since pip v.10
print(user_cache_dir('pip'))
print(user_cache_dir('wheel'))

Under the hood, it normalizes paths, manages different locations for exotic and ordinary operating systems and platforms, performs Windows registry lookup.

It may worth mentioning, if you have different Python versions installed, 2.x'es and 3.x'es, they all do share the same cache location.

查看更多
Lonely孤独者°
4楼-- · 2019-01-10 23:05

You can backup the associated wheel rather than attempting to perform a backup of the cache folder.

Download the wheel for csselect of version 0.9.1 into /tmp/wheelhouse:

pip wheel --wheel-dir=/tmp/wheelhouse cssselect==0.9.1

Install the downloaded wheel:

pip install /tmp/wheelhouse/cssselect-0.9.1-py2-none-any.whl
查看更多
登录 后发表回答