Python PIP local cache
Receive new Django tutorials.
PIP is the Python Package Manager that allows Python developers and users to easily install Python packages published on the pip remote register by other developers .
If you are using the pip manager frequently then you may find this quick tip useful ,where I'll show how you can activate or enable the local cache of pip which is going to boost the download speed of pip packages .
The idea behind the pip cache is simple ,when you install a Python package using pip for the first time ,it gets saved on the cache .If you try to download/install the same version of the package on a second time ,pip will just use the local cached copy instead of retrieving it from the remote register .
Enabling the local cache of pip
Enabling the local cache of pip is fairly simple so let's do it step by step .
First open the pip configuration file located at ~/.pip/pip.conf with your preferred text editor .
The configuration file can be also located in ~/.config/pip/pip.conf or in /etc/pip.conf
$HOME/.pip/pip.conf on Unix and MAC
%HOME%\pip\pip.ini on Windows .
Or you can even use a custom file and location for PIP config file using the environment variable PIP_CONFIG_FILE
If you are inside a virtualenv ,you can find the config file in $VIRTUAL_ENV/pip.conf on Unix based systems and %VIRTUAL_ENV%\pip.ini on Windows .
You can find more information about the PIP configuration file here
Then copy and add this
[global] no-cache-dir = false download-cache=/usr/local/pip/cache
Next create the folder
mkdir -p /usr/local/pip/cache
Then give it write access
chmod -R 755 /usr/local/pip/cache
You can instead use your profile config file ~/.bash_profile
So open ~/.bash_profile .
That is it ! I hope this was helpful for you .
About the Author
Read our other tutorials
- Angular Tutorial
- Laravel 6 Tutorial
- React Tutorial
- React Hooks Tutorial
- React Native Tutorial
- Webpack Tutorial
- PHP Tutorial
- Django Tutorial
- Java Spring Tutorial
- Rails 6 Tutorial
- Ionic 4 Tutorial
- TypeScript Tutorial
- Bootstrap 4 Tutorial
- Electron Tutorial
- Cordova Tutorial
- HTML Tutorial
- GraphQL Tutorial
- CSS Grid Layout Tutorial
- PWA Tutorial