177
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
.
1135
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
- [Django]-Multiple annotate Sum terms yields inflated answer
- [Django]-Django urlsafe base64 decoding with decryption
- [Django]-What does 'many = True' do in Django Rest FrameWork?
206
pip list -v
can be used to list packages’ install locations, introduced in https://pip.pypa.io/en/stable/news/#b1-2018-03-31
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 https://github.com/pypa/pip/issues/5599 for suitable ways of upgrading pip
or pip3
.
- [Django]-Django Installed Apps Location
- [Django]-Django, Models & Forms: replace "This field is required" message
- [Django]-Choose test database?
62
Easiest way is probably
pip3 -V
This will show you where your pip is installed and therefore where your packages are located.
- [Django]-Are Django SECRET_KEY's per instance or per app?
- [Django]-Django: Record with max element
- [Django]-How to test "render to template" functions in django? (TDD)
27
In a Python interpreter or script, you can do
import site
site.getsitepackages() # List of global package locations
and
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
['/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages']
,
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
/usr/local/lib/python3.7/site-packages
Reference: https://docs.python.org/3/library/site.html#site.getsitepackages
- [Django]-Data Mining in a Django/Postgres application
- [Django]-Django connection to postgres by docker-compose
- [Django]-Django – how to unit test a post request using request.FILES
26
The safest way is to call pip
through the specific python
that you are executing. If you run pip show pip
directly, it may be calling a different pip
than the one that python
is calling. Examples:
$ python -m pip show pip
$ python3 -m pip show pip
$ /usr/bin/python -m pip show pip
$ /usr/local/bin/python3 -m pip show pip
Here’s an example showing how they can differ:
$ pip show pip
Location: /usr/local/lib/python3.9/site-packages
$ python -m pip show pip
Location: /Library/Python/2.7/site-packages
- [Django]-How can I handle Exceptions raised by dango-social-auth?
- [Django]-What is the difference render() and redirect() in Django?
- [Django]-Uninstall Django completely
24
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.
- [Django]-How to add a cancel button to DeleteView in django
- [Django]-Django: manage.py does not print stack trace for errors
- [Django]-Django testing: Test the initial value of a form field
13
One can import the package then consult its help
import statsmodels
help(sm)
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).
- [Django]-Django 1.8 KeyError: 'manager' on relationship
- [Django]-Django: remove a filter condition from a queryset
- [Django]-How to run a celery worker with Django app scalable by AWS Elastic Beanstalk?
5
% python -c "import sysconfig; print(sysconfig.get_path('purelib'))"
/opt/homebrew/lib/python3.11/site-packages
% pip show yt-dlp
Name: yt-dlp
Version: 2023.3.4
Summary: A youtube-dl fork with additional features and patches
Home-page: https://github.com/yt-dlp/yt-dlp
Author:
Author-email:
License:
Location: /opt/homebrew/lib/python3.11/site-packages
Requires: brotli, certifi, mutagen, pycryptodomex, websockets
Required-by:
How do I find the location of my Python site-packages directory?
or shorter python -m pip show pip
- [Django]-Default filter in Django model
- [Django]-How to server HTTP/2 Protocol with django
- [Django]-Django: manage.py does not print stack trace for errors
0
If you have installed packages via pip and are running the code on Windows, the package should be located in one of the following directories:
User Site Packages: C:\Users\USERNAME\AppData\Roaming\Python\PythonXX\site-packages
Global Site Packages: C:\Program Files\PythonXX\Lib\site-packages
Note that "USERNAME" and "XX" will depend on your system configuration and the version of Python you are using. Also, if you have installed Python in a different location than the default, the paths may differ.
If you’re not sure where the package is installed, you can open a command prompt and type pip show ‘package-name’. This will show you the installation location of the package.
- [Django]-ValueError: The field admin.LogEntry.user was declared with a lazy reference
- [Django]-Determine variable type within django template
- [Django]-Resource temporarily unavailable using uwsgi + nginx