Where Do Pip Installs Go: A Practical Python Guide for Devs
Learn where pip installs place Python packages, how to locate system-wide, user, and virtual environment paths, and best practices for reliable dependency management. This Install Manual guide covers commands, tips, and common pitfalls.

Pip installs place packages in the active Python environment's site-packages directory. In a system-wide Python, this is the global path; for a per-user setup, it uses the user site-packages directory. Within a virtual environment, installs go to the venv's site-packages. Reveal the exact path with python -m site --user-site or a small Python snippet that prints site.get_site_packages().
Understanding Python environments and site-packages
Pip installs place packages in the active Python environment's site-packages directory. In a system-wide Python, this is the global site-packages path; for a per-user setup, it uses the user site-packages directory. Inside a virtual environment, installs go to the venv's site-packages. To discover the exact location for your setup, you can reveal paths with a couple of simple commands:
python -m site --user-siteimport site
print(site.get_site_packages())Line-by-line: The --user-site path usually resides under your home folder, while the global path depends on how Python was installed. In a virtual environment, the path is nested inside your project directory. For cross-platform scripts, rely on site and sysconfig for discovery. Common variations include using sysconfig.get_paths()['purelib'] to reflect the platform-specific lib path.
code_fences_language_for_first_block_only_override_allowed_for_json_to_markdown_allowed_through_rules_print}
OS-level locations you should know
Different operating systems place Python packages in slightly different standard locations. Knowing these helps debugging import errors and understanding where new packages land when you install with pip.
- Linux/macOS (global): typically under the system’s Python site-packages directory, e.g.
/usr/local/lib/pythonX.Y/site-packagesor/usr/lib/pythonX.Y/site-packages. - Linux/macOS (user): the user site-packages path, commonly
~/.local/lib/pythonX.Y/site-packages. - Windows (global): something like
C:\PythonXY\Lib\site-packages. - Windows (user): often under the user profile, e.g.
C:\Users\<User>\AppData\Local\Programs\Python\PythonXY\Lib\site-packagesor via the user-site path.
To verify on your machine, you can print paths with the following commands:
# Print user-site path (Linux/macOS/Windows with proper Python on PATH)
python -m site --user-site# Print global path example using sysconfig (portable across platforms)
python -c "import sysconfig; print(sysconfig.get_paths()['purelib'])" If you’re unsure which is active, check the Python executable you’re calling with which python (Linux/macOS) or where python (Windows).
code_fences_language_for_first_block_only_override_allowed_for_json_to_markdown_allowed_through_rules_print}
Using Python tooling to discover the exact path
When you need an exact, reliable path for your current environment, rely on Python tooling rather than manual guesses. The following commands reveal the path to the site-packages directory used by the active Python interpreter.
# List all known site-packages-like paths
python -m siteimport sysconfig
print(sysconfig.get_paths()["purelib"])# Also useful to print the user-site path explicitly
python -m site --user-siteIf your project uses multiple Python versions, repeat these steps for the interpreter you plan to use. This ensures you install and import against the expected runtime, avoiding subtle conflicts.
code_fences_language_for_first_block_only_override_allowed_for_json_to_markdown_allowed_through_rules_print}
Distinguishing system-wide, user, and virtual environments
Understanding the three main install targets helps avoid confusion:
- System-wide (global): Packages are available to all users of the system when you install without any flags.
- User (per-user): Installs go into a user-specific directory, avoiding the need for admin privileges and enabling per-user customization.
- Virtual environments (venv): Each project gets its own isolated site-packages directory, completely segregating dependencies.
To illustrate, here is the end-to-end flow:
# 1) Create a venv for the project
python -m venv venv
# 2) Activate the venv (Linux/macOS)
source venv/bin/activate
# 3) Install a package inside the venv
pip install requestsFor Windows:
python -m venv venv
venv\Scripts\activate
pip install requestsRemember: use pip tied to the intended interpreter (e.g., the one in your venv). Mixing interpreters is a common source of confusion when evaluating where pip installs go.
code_fences_language_for_first_block_only_override_allowed_for_json_to_markdown_allowed_through_rules_print}
Custom install locations with --target and --prefix
Pip lets you place packages in non-default locations when you have special requirements, testing, or constrained environments. Two common options are:
--targetto install into a specific directory (not a Python site-packages path):
pip install --target="/path/to/dir" somepackage--prefixto install into a custom prefix, which can create a site-packages path under that prefix:
pip install --prefix="/custom/prefix" somepackageNote: Packages installed with these options may not be automatically discovered by Python’s standard import system unless you adjust PYTHONPATH or install a corresponding .pth file in the target. Use this approach sparingly and test imports after installation.
code_fences_language_for_first_block_only_override_allowed_for_json_to_markdown_allowed_through_rules_print}
Verifying installation path and import path
To confirm exactly where a package landed and how Python will import it, verify both the installation metadata and the import path.
# Show package metadata (location, version, etc.)
pip show requestsimport requests
print(requests.__file__)If you’re using a virtual environment, make sure it’s activated before running these checks. If the output shows a path inside a venv, you know you’re in the right, isolated environment. If not, you may be accidentally using system-wide installations or a different interpreter.
code_fences_language_for_first_block_only_override_allowed_for_json_to_markdown_allowed_through_rules_print}
Common pitfalls and how to avoid them
Even seasoned developers trip over Python path issues. Here are frequent culprits and quick fixes:
- Mixing pip from different Python installations (e.g.,
pipfrom Python 3.8 with Python 3.11). Always runpython -m pipfrom the intended interpreter. - Assuming a global site-packages path applies to all environments. Rely on
siteandsysconfigto discover the correct path for your current interpreter. - Failing to activate a virtual environment before installing. Always activate first to ensure isolation.
Code examples for checking paths:
# Ensure the right interpreter is used
which python
which pip# Windows alternative
Get-Command python
Get-Command pipWhen in doubt, print the path programmatically as shown earlier to confirm the active environment’s site-packages location.
code_fences_language_for_first_block_only_override_allowed_for_json_to_markdown_allowed_through_rules_print}
Best practices for managing Python dependencies
Adopt consistent, repeatable practices to keep projects healthy:
- Use a virtual environment for every project to ensure clean, reproducible installs.
- Pin exact versions in a requirements.txt file and use
pip install -r requirements.txtto reproduce environments. - Prefer local, project-scoped installs via venv over global installs for security and compatibility.
- Regularly verify your environment by listing installed packages and checking import paths.
Code sample for a typical workflow:
python -m venv env
source env/bin/activate
pip install -r requirements.txt
python -m pip freeze > frozen.txtThis workflow ensures that your development and deployment stages consistently use the same dependencies and paths.
code_fences_language_for_first_block_only_override_allowed_for_json_to_markdown_allowed_through_rules_print}
Quick troubleshooting checklist
When packages don’t appear where you expect, follow this quick checklist:
# 1) Update pip to the latest compatible version
python -m pip install --upgrade pip
# 2) Reinstall the package in the active environment
pip install --force-reinstall somepackage
# 3) Verify interpreter and environment alignment
which python
python -m siteIf issues persist, double-check that your IDE or runtime is configured to use the same interpreter as your shell, and verify that the PYTHONPATH or PYTHONHOME variables are not forcing alternative paths.
code_fences_language_for_first_block_only_override_allowed_for_json_to_markdown_allowed_through_rules_print}
Advanced: editable installs and wheels
For development workflows, editable installs let you modify source code and have changes reflected immediately without reinstalling. Use pip install -e with a local project path, often used with a setup.py or pyproject.toml.
# Editable install from a local project directory
pip install -e /path/to/projectWheels provide prebuilt distributions. Prefer wheel packages to minimize build requirements and ensure faster installations. You can inspect wheel info or install a wheel directly:
# Install a wheel file directly
pip install somepackage-1.2.3-py3-none-any.whlUnderstanding the difference between editable installs and wheels helps you manage source changes vs. stable binaries and clarifies why installed locations may differ in each case.
code_fences_language_for_first_block_only_override_allowed_for_json_to_markdown_allowed_through_rules_print}
Appendix: how to locate for multiple Python versions
If you manage multiple Python versions (e.g., 3.9 and 3.11), repeat the path discovery steps for each interpreter. A common pattern is to invoke the specific python executable explicitly, ensuring you’re inspecting the intended runtime:
# Python 3.9 path discovery
python3.9 -m site
python3.9 -c "import sysconfig; print(sysconfig.get_paths()['purelib'])"
# Python 3.11 path discovery
python3.11 -m site
python3.11 -c "import sysconfig; print(sysconfig.get_paths()['purelib'])"This explicit attention to interpreter paths prevents cross-version contamination of your installed packages.
code_fences_language_for_first_block_only_override_allowed_for_json_to_markdown_allowed_through_rules_print}
Steps
Estimated time: 15-25 minutes
- 1
Confirm Python version and environment
Run python --version and which python (or where python) to identify the interpreter you’ll use for installation. This avoids cross-interpreter confusion when locating site-packages.
Tip: Always pick one Python installation for a project to avoid mixed paths. - 2
Create and activate a virtual environment
Create an isolated environment to host your dependencies. Activate it before installing to ensure your packages stay project-scoped.
Tip: Remember Windows activation differs from Unix-like systems. - 3
Install packages inside the environment
With the venv active, use pip to install your packages. Verify installation with pip list or pip show.
Tip: Prefer pinned versions for reproducible environments. - 4
Locate the site-packages path programmatically
Use Python tooling to reveal the exact site-packages path for your interpreter.
Tip: If in doubt, print site.get_site_packages() or sysconfig.get_paths()['purelib']. - 5
Experiment with --user and --target
Try a per-user install and a targeted install to see how paths differ. This builds intuition for deployment constraints.
Tip: Remember that --target may require adjusting PYTHONPATH. - 6
Verify imports after installation
Open a Python shell and import the package to confirm the path is discoverable by Python.
Tip: If import fails, check PATH and interpreter alignment. - 7
Document environment details
Record the interpreter path and site-packages location in your project docs for future maintenance.
Tip: Documentation saves debugging time later.
Prerequisites
Required
- Required
- pip (bundled with Python 3.8+ by default)Required
- Basic command-line knowledgeRequired
Optional
- Option to use a virtual environment (recommended)Optional
Commands
| Action | Command |
|---|---|
| Show user-site path | python -m site --user-site |
| Show global/purelib path (system-wide or current interpreter)Prints the path to the site-packages directory for the active interpreter | python -c "import sysconfig; print(sysconfig.get_paths()['purelib'])" |
| Create a virtual environmentCreates an isolated environment named 'venv' in the current directory | python -m venv venv |
| Activate virtual environment (Linux/macOS)Requires shell activation on Unix-like systems | — |
| Activate virtual environment (Windows)Requires activation in PowerShell or CMD on Windows | — |
| Install a package in the current environmentUses the active interpreter’s pip within an active venv or per-user/global env | — |
| Install to a custom directory with --targetDoes not modify site-packages; imports may require PYTHONPATH | — |
Got Questions?
Where does pip install packages by default on Linux/macOS?
By default, pip installs to the active interpreter’s site-packages directory, which on Linux/macOS usually resides in the Python installation’s site-packages. The exact path varies by Python version and how Python was installed. Use python -m site or sysconfig to confirm.
Pip installs to the current Python environment's site-packages directory; check with python -m site to know the exact path for your setup.
How can I tell pip to install to a specific directory?
Use the --target or --prefix options with pip. --target installs into a chosen directory, while --prefix changes the installation prefix. Note that packages in non-standard locations may require PYTHONPATH adjustments for Python to import them.
You can direct pip to a folder with --target or a custom prefix, but you may need to update PYTHONPATH so Python finds them.
What’s the difference between system-wide, user, and venv installs?
System-wide installs affect all users and require admin rights. User installs affect only the invoking user and avoid admin rights. Virtual environments (venv) provide project-scoped isolation, ensuring dependencies don’t leak between projects.
System-wide affects everyone, user installs are per-user, and venvs isolate a project’s dependencies.
How do I know which Python installation pip is using?
Run python -m pip --version or which pip (or where pip on Windows) to verify which Python installation is bound to pip. Always rely on python -m pip so you’re using the same interpreter as your Python command.
Check which Python and pip you’re invoking to avoid mismatches.
Why can’t I import a package after installing with pip?
This usually means the package was installed in a different Python or environment than the one used to run your code. Verify the active interpreter and path, and reinstall within the correct environment.
Import errors often mean you installed in the wrong environment; confirm your interpreter and environment.
Should I use virtual environments for every project?
Yes. Virtual environments help avoid dependency conflicts by keeping each project’s packages separate. They simplify deployment and make it safer to upgrade or test new packages without breaking other projects.
Absolutely—virtual environments are a best practice for reliable Python projects.
Main Points
- Know where site-packages lives per environment
- Use virtual environments to isolate projects
- Discover paths with site/sysconfig tools
- Avoid mixing interpreters and environments
- Use --target for custom install locations when needed