python – Where does pip install its packages?

The Question :

397 people think this question is useful

I activated a virtualenv which has pip installed. I did

pip3 install Django==1.8

and Django successfully downloaded. Now, I want to open up the Django folder. Where is the folder located?

Normally it would be in “downloads”, but I’m not sure where it would be if I installed it using pip in a virtualenv.

The Question Comments :
  • Can the directory in which to install packages be overridden via CLI args, environment variables or a config file?

The Answer 1

128 people think this answer is useful

pip when used with virtualenv will generally install packages in the path <virtualenv_name>/lib/<python_ver>/site-packages.

For example, I created a test virtualenv named venv_test with Python 2.7, and the django folder is in venv_test/lib/python2.7/site-packages/django.

The Answer 2

704 people think this answer is useful

pip show <package name> will provide the location for Windows and macOS, and I’m guessing any system. 🙂

For example:

> pip show cvxopt
Name: cvxopt
Version: 1.2.0
Location: /usr/local/lib/python2.7/site-packages

The Answer 3

80 people think this answer is useful

pip list -v can be used to list packages’ install locations, introduced in

Show install locations when list command ran with “-v” option. (#979)

>pip list -v
Package                  Version   Location                                                             Installer
------------------------ --------- -------------------------------------------------------------------- ---------
alabaster                0.7.12    c:\users\me\appdata\local\programs\python\python38\lib\site-packages pip
apipkg                   1.5       c:\users\me\appdata\local\programs\python\python38\lib\site-packages pip
argcomplete              1.10.3    c:\users\me\appdata\local\programs\python\python38\lib\site-packages pip
astroid                  2.3.3     c:\users\me\appdata\local\programs\python\python38\lib\site-packages pip

This feature is introduced in pip 10.0.0b1. On Ubuntu 18.04 (Bionic Beaver), pip or pip3 installed with sudo apt install python-pip or sudo apt install python3-pip is 9.0.1 which doesn’t have this feature.

Check for suitable ways of upgrading pip or pip3.

The Answer 4

25 people think this answer is useful

Easiest way is probably

pip3 -V

This will show you where your pip is installed and therefore where your packages are located.

The Answer 5

14 people think this answer is useful

By default, on Linux, Pip installs packages to /usr/local/lib/python2.7/dist-packages.

Using virtualenv or –user during install will change this default location. If you use pip show make sure you are using the right user or else pip may not see the packages you are referencing.

The Answer 6

13 people think this answer is useful

In a Python interpreter or script, you can do

import site
site.getsitepackages() # List of global package locations


site.getusersitepackages() # String for user-specific package location

For locations third-party packages (those not in the core Python distribution) are installed to.

On my Homebrew-installed Python on macOS, the former outputs


which canonicalizes to the same path output by pip show, as mentioned in a previous answer:

$ readlink -f /usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages


The Answer 7

6 people think this answer is useful

One can import the package then consult its help

import statsmodels

At the very bottom of the help there is a section FILE that indicates where this package was installed.

This solution was tested with at least matplotlib (3.1.2) and statsmodels (0.11.1) (python 3.8.2).

Add a Comment