Search code examples
pythonpip

How to tell Pip where to cache wheel files?


When I install packages onto my Linux server using Pip, I'd like for pip to cache the wheels it downloads into a directory other than the default, which is ~/.cache/pip. I'm trying to specify the cache directory as 'pkg_cache' in my ~/.config/pip/pip.conf file like this:

[global]
index-url = http://packages.example.com:8081/simple
extra-index-url = https://pypi.org/simple
trusted-host = packages.example.com
download-cache = $HOME/project/pkg_cache

But when I do my 'pip install' the wheel files aren't being saved in the pkg_cache directory, even if I set the permissions to that directory to 777. What am I doing wrong?


Solution

  • The problem is $HOME. Pip's configuration file is not a shell script and there is no shell variable expansion. Try using a concrete path instead.

    Also check the configuration options of your pip with pip --help. I have version 10.0.1 and there is no such option as download-cache, but there is cache-dir:

    --cache-dir <dir> Store the cache data in <dir>.