Where does pip install its packages?
Whenever you pip install
something, it finds its humble home in the site-packages directory:
Within an active virtual environment, the location changes:
These spells reveal the lair of our pip-installed Python packages.
Pinpointing a package's residence
To locate a specific package's home within your system, orchestrate:
Here, you’ll be presented with the name, version, and the location of your queried package.
Handling virtual environments
In a virtual environment, the packages typically unpack their bags at:
Remember: Packages installed here won't bother packages outside this secluded space.
Tracking all package locations
For an eagle's view of all package habitats, execute:
Note: You're dealing with pip 10.0.0 or above here! Please refer to pip's official instructions if you need to upgrade pip.
Checking pip3's directory
To peer into pip3's world (Python 3.x) and its installation directory:
Digging up site module's secrets
Python's site
module offers secrets about both global and user-specific package locations:
To ensure you're walking the exact path, consider coupling this with readlink
.
Zooming in on a Django package
If you have Django installed via pip and need to know its secret hideout:
Replace "django" with the package of your choice.
Unwrapping installation precedence
Just like you have a preference for a particular room in your house, pip has a preference: 🎒→🏠→🛌.
Combatting conflicts and issues
Use pipdeptree
to deal with version conflicts and installation issues:
Managing package locations
Knowing package locations can come in handy during:
- Debugging: Knowing a package's location can be a bug exterminator.
- Web Development: Django or Flask, you name it!
- Environment Isolation: Different projects, different requirements.
- Dependency Management: Different stages require different versions.
Was this article helpful?