The ProblemJump To Solution
Where does Python’s pip
install packages?
The Solution
The location of pip
packages will vary between systems and projects based on the operating system, the installing user, and whether or not a virtual environment is in use. Different pip
packages may be installed in different places on the same system. Therefore, the best way to find the location of a package is through pip
’s show
command.
Click to Copy
pip show numpy
This command will display various information about the package, including its location on disk. For example, the below output shows a local user installation of numpy
on a Linux system:
Click to Copy
Location: /home/user/.local/lib/python3.10/site-packages
To view the locations of all Python packages, you can use pip list -v
. In the output below, different packages are installed locally and globally:
Click to Copy
Package Version Location Installer---------------------------- --------------- ------------------------------------------------------------- ---------absl-py 1.2.0 /home/user/.local/lib/python3.10/site-packages pipaccelerate 0.12.0 /home/user/.local/lib/python3.10/site-packages pipaddict 2.4.0 /home/user/.local/lib/python3.10/site-packages pipaiocmd 0.1.5 /usr/lib/python3.10/site-packagesaiofiles 22.1.0 /usr/lib/python3.10/site-packages pipaiohttp 3.8.1 /home/user/.local/lib/python3.10/site-packages pipaiorpcX 0.22.1 /usr/lib/python3.10/site-packagesaiosignal 1.2.0 /home/user/.local/lib/python3.10/site-packages pip
FAQs
Different pip packages may be installed in different places on the same system. Therefore, the best way to find the location of a package is through pip 's show command.
Where does pip store Python packages? ›
By default, Python packages installed through pip using the ' --user ' flag will be stored in your home directory depending on the specific version of Python they were installed with. Your home directory location, also equivalent to $HOME, will be noted by a ~.
How to find Python packages location? ›
Locally installed Python and all packages will be installed under a directory similar to ~/. local/bin/ for a Unix-based system, or \Users\Username\AppData\Local\Programs\ for Windows.
How to tell pip where to look for packages? ›
Finding Packages
pip looks for packages in a number of places: on PyPI (or the index given as --index-url , if not disabled via --no-index ), in the local filesystem, and in any additional repositories specified via --find-links or --extra-index-url .
Where are default pip packages located? ›
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.
How to see pip installed packages? ›
To get a list of installed packages in Python, you can use the pip command-line tool with the list command. This will show all packages installed in the current environment.
Where does pip install get packages from? ›
Although pip uses PyPi as a default repository for fetching packages, it has also the capability to install packages from other sources, including: Version control systems like Github, Mercurial, Subversion, and Bazaar. Requirements files. Usually, Python packages require multiple packages to run.
Where are Python packages hosted? ›
PyPI primarily hosts Python packages in the form of source archives, called "sdists", or of "wheels" that may contain binary modules from a compiled language.
How to find where Python is installed? ›
Follow the steps below:
- Step 1: Open Terminal. You can open Terminal by searching for it in the Start menu and selecting "Terminal"
- Step 2: Use the Get-Command Command. In the Terminal window, type the following command: (Get-Command python).Path. Press Enter, and Terminal will reveal the paths where Python is installed.
What is the default location for Python site packages? ›
Default value is ~/. local/lib/pythonX.Y/site-packages for UNIX and non-framework macOS builds, ~/Library/Python/X.Y/lib/python/site-packages for macOS framework builds, and %APPDATA%\Python\PythonXY\site-packages on Windows.
When dealing with Python installations, we've noticed that third-party Python libraries may be installed in one of several directories:
- lib/pythonX. ...
- lib64/pythonX. ...
- lib/pythonX/dist-packages on Debian/Ubuntu with system Python.
- lib/python/site-packages on macOS with framework Python.
- Lib/site-packages on Windows.
- others?
How do I find the location of a Python file? ›
We can get the location (path) of the running script file . py with __file__. __file__ is useful for reading other files and it gives the current location of the running file.
Where does Python look for modules? ›
Python looks for modules in “sys.
It looks for a file called a_module.py in the directories listed in the variable sys. path .
How do I find pip package dependencies? ›
You'll need to view dependencies using one of these three commands in Python:
- Pip show displays information about one or more of your installed packages.
- Pipdeptree shows dependencies as a tree using a command line utility.
- Pip list will list installed packages with various conditions.
Where can I find my pip file? ›
The PIP configuration file can be found at %HOME%\pip\pip. ini. Pip also contains a legacy per-user configuration file. This file is located at %APPDATA%\pip\pip.
Where does pip install pull packages from? ›
Although pip uses PyPi as a default repository for fetching packages, it has also the capability to install packages from other sources, including: Version control systems like Github, Mercurial, Subversion, and Bazaar. Requirements files. Usually, Python packages require multiple packages to run.
Where does pip store downloaded files? ›
Overview. pip download does the same resolution and downloading as pip install , but instead of installing the dependencies, it collects the downloaded distributions into the directory provided (defaulting to the current directory).
How do I know where pip is installed Windows? ›
How to check if pip is installed on Windows and Mac: In Command Prompt on Windows or Terminal on Mac, type and enter: pip --version . If pip version is shown then it is installed.
Where does pip install -- user install to? ›
Here's where the --user flag makes the difference. When you use pip install --user cowsay , it directs pip to install packages in a user-specific location, typically ~/. local/lib/python${PY_MAJOR}.