There are two types of site-packages directories, global and per user.

  1. Global site-packages ("dist-packages") directories are listed in sys.path when you run:

     python -m site
    

    For a more concise list run getsitepackages from the site module in Python code:

     python -c 'import site; print(site.getsitepackages())'
    

    Caution: In virtual environments getsitepackages is not available with older versions of virtualenv, sys.path from above will list the virtualenv's site-packages directory correctly, though. In Python 3, you may use the sysconfig module instead:

     python3 -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])'
    
  2. The per user site-packages directory (PEP 370) is where Python installs your local packages:

     python -m site --user-site
    

    If this points to a non-existing directory check the exit status of Python and see python -m site --help for explanations.

    Hint: Running pip list --user or pip freeze --user gives you a list of all installed per user site-packages.


Practical Tips

  • <package>.__path__ lets you identify the location(s) of a specific package: (details)

      $ python -c "import setuptools as _; print(_.__path__)"
      ['/usr/lib/python2.7/dist-packages/setuptools']
    
  • <module>.__file__ lets you identify the location of a specific module: (difference)

      $ python3 -c "import os as _; print(_.__file__)"
      /usr/lib/python3.6/os.py
    
  • Run pip show <package> to show Debian-style package information:

      $ pip show pytest
      Name: pytest
      Version: 3.8.2
      Summary: pytest: simple powerful testing with Python
      Home-page: https://docs.pytest.org/en/latest/
      Author: Holger Krekel, Bruno Oliveira, Ronny Pfannschmidt, Floris Bruynooghe, Brianna Laugher, Florian Bruhin and others
      Author-email: None
      License: MIT license
      Location: /home/peter/.local/lib/python3.4/site-packages
      Requires: more-itertools, atomicwrites, setuptools, attrs, pathlib2, six, py, pluggy
    
Answer from Peterino on Stack Overflow
Top answer
1 of 16
1184

There are two types of site-packages directories, global and per user.

  1. Global site-packages ("dist-packages") directories are listed in sys.path when you run:

     python -m site
    

    For a more concise list run getsitepackages from the site module in Python code:

     python -c 'import site; print(site.getsitepackages())'
    

    Caution: In virtual environments getsitepackages is not available with older versions of virtualenv, sys.path from above will list the virtualenv's site-packages directory correctly, though. In Python 3, you may use the sysconfig module instead:

     python3 -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])'
    
  2. The per user site-packages directory (PEP 370) is where Python installs your local packages:

     python -m site --user-site
    

    If this points to a non-existing directory check the exit status of Python and see python -m site --help for explanations.

    Hint: Running pip list --user or pip freeze --user gives you a list of all installed per user site-packages.


Practical Tips

  • <package>.__path__ lets you identify the location(s) of a specific package: (details)

      $ python -c "import setuptools as _; print(_.__path__)"
      ['/usr/lib/python2.7/dist-packages/setuptools']
    
  • <module>.__file__ lets you identify the location of a specific module: (difference)

      $ python3 -c "import os as _; print(_.__file__)"
      /usr/lib/python3.6/os.py
    
  • Run pip show <package> to show Debian-style package information:

      $ pip show pytest
      Name: pytest
      Version: 3.8.2
      Summary: pytest: simple powerful testing with Python
      Home-page: https://docs.pytest.org/en/latest/
      Author: Holger Krekel, Bruno Oliveira, Ronny Pfannschmidt, Floris Bruynooghe, Brianna Laugher, Florian Bruhin and others
      Author-email: None
      License: MIT license
      Location: /home/peter/.local/lib/python3.4/site-packages
      Requires: more-itertools, atomicwrites, setuptools, attrs, pathlib2, six, py, pluggy
    
2 of 16
707
>>> import site; site.getsitepackages()
['/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages']

(or just first item with site.getsitepackages()[0])

🌐
GeeksforGeeks
geeksforgeeks.org › python › get-location-of-python-site-packages-directory
Get Location of Python site-packages Directory - GeeksforGeeks
July 23, 2025 - py -c "import site; print(site.getsitepackages())" ... This gives a list containing the path of site-packages and the default python distribution where the site-packages directory would contain the list of all the packages installed in Python.
People also ask

Is there a difference between site-packages and dist-packages
ANS: In most Python installations, they serve the same purpose. However, Debian-based systems like Ubuntu often use dist-packages for system-installed Python libraries managed by the OS package manager, while site-packages might be used for user-installed packages or within virtual environments.
🌐
sqlpey.com
sqlpey.com › python › locating-python-site-packages
Locating Python Site-Packages Directories: Methods and Best Practices
Which method is best for finding site-packages
ANS: For modern Python (3.2+), using sysconfig is generally recommended due to its reliability across different environments and its inclusion in the standard library. For specific package locations, pip show is very convenient.
🌐
sqlpey.com
sqlpey.com › python › locating-python-site-packages
Locating Python Site-Packages Directories: Methods and Best Practices
Why would I need to find the site-packages directory
ANS: You might need to locate it to manually inspect installed package files, troubleshoot import errors, or ensure your development environment is configured correctly.
🌐
sqlpey.com
sqlpey.com › python › locating-python-site-packages
Locating Python Site-Packages Directories: Methods and Best Practices
🌐
Codemia
codemia.io › home › knowledge hub › how do i find the location of my python site-packages directory?
How do I find the location of my Python site-packages directory? | Codemia
December 28, 2024 - The fastest way to find your Python site-packages directory is to run python -m site or python -c "import site; print(site.getsitepackages())". The site-packages directory is where pip installs third-party packages for a specific Python interpreter, ...
🌐
Python
docs.python.org › 3 › library › site.html
site — Site-specific configuration hook — Python 3.15.2 documentation
3 weeks ago - Path to the user site-packages for the running Python. Can be None if getusersitepackages() hasn’t been called yet.
🌐
W3docs
w3docs.com › python
How do I find the location of my Python site-packages directory? | W3Docs
You can use the site module to find the location of your Python site-packages directory.
🌐
Python.org
discuss.python.org › python help
Site Packages location - Python Help - Discussions on Python.org
September 30, 2022 - I’m trying to find the site packages folder to save my modules to. I’m using Windows 10 Home, I have looked everywhere and can’t find it. Can someone tell me an easy way to get to it?
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › how-do-i-find-the-location-of-my-python-site-packages-directory
How do I find the location of my Python site-packages directory?
May 15, 2025 - sys.path = [ 'C:\current\directory', 'C:\Python312\python312.zip', 'C:\Python312\DLLs', 'C:\Python312\Lib', 'C:\Python312', 'C:\Python312\Lib\site-packages', ] USER_BASE: 'C:\Users\username\AppData\Roaming\Python' USER_SITE: 'C:\Users\username\AppData\Roaming\Python\Python312\site-packages' ENABLE_USER_SITE: True · Use sysconfig.get_paths()["purelib"] for the most reliable method across different environments.
🌐
w3resource
w3resource.com › python-exercises › python-basic-exercise-44.php
Python: Locate Python site-packages - w3resource
# 'site.getsitepackages()' returns a list of paths where site packages are installed. print(site.getsitepackages()) ... ['/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.5/dist-packages ']
🌐
sqlpey
sqlpey.com › python › locating-python-site-packages
Locating Python Site-Packages Directories: Methods and Best Practices
November 4, 2025 - # Example within a venv on Linux /tmp/.venv/lib/python3.12/site-packages · Retrieving all paths: The get_paths() function returns a dictionary of all relevant installation directories:
🌐
Runebook.dev
runebook.dev › en › docs › python › library › site › site.getsitepackages
Mastering Python Package Paths: Beyond site.getsitepackages()
The function site.getsitepackages() is designed to return a list of directory names where globally-installed third-party packages (the "site-packages" directories) are located for the current Python installation.
🌐
Leemendelowitz
leemendelowitz.github.io › blog › how-does-python-find-packages.html
How does python find packages? // Lee On Coding // My blog about coding and stuff.
>>> import sys >>> print '\n'.join(sys.path) /usr/lib/python2.7 /usr/lib/python2.7/plat-x86_64-linux-gnu /usr/lib/python2.7/lib-tk /usr/lib/python2.7/lib-old /usr/lib/python2.7/lib-dynload /usr/local/lib/python2.7/dist-packages /usr/lib/python2.7/dist-packages · >>> import sys >>> print '\n'.join(sys.path) /usr/local/lib/python27.zip /usr/local/lib/python2.7 /usr/local/lib/python2.7/plat-linux2 /usr/local/lib/python2.7/lib-tk /usr/local/lib/python2.7/lib-old /usr/local/lib/python2.7/lib-dynload /usr/local/lib/python2.7/site-packages
🌐
Medium
medium.com › @imsrv01 › python-packages-300785410b2f
Python — Packages. Package/Module location | by Shantaram (Shan) Vernekar | Medium
July 12, 2022 - Local packages are installed under current user home directory. Path to the site-packages directory can be found using below command. python -m site — user-site#example ~/.local/lib/python3.8/site-packages
🌐
YouTube
youtube.com › bytive
How do I find the location of my Python site-packages directory? - YouTube
Thanks for watching this video !Don't forget to drop a like and share it with your friends !Subscribe to the Hackanon's channel for more such interesting vid...
Published: June 29, 2022
Views: 3K
🌐
Python
svn.python.org › projects › python › trunk › Lib › site.py
site.py
None: Disabled for security reasons False: Disabled by user (command line option) True: Safe and enabled """ if sys.flags.no_user_site: return False if hasattr(os, "getuid") and hasattr(os, "geteuid"): # check process uid == effective uid if os.geteuid() != os.getuid(): return None if hasattr(os, "getgid") and hasattr(os, "getegid"): # check process gid == effective gid if os.getegid() != os.getgid(): return None return True def getuserbase(): """Returns the `user base` directory path. The `user base` directory can be used to store data. If the global variable ``USER_BASE`` is not initialized yet, this function will also set it. """ global USER_BASE if USER_BASE is not None: return USER_BASE from sysconfig import get_config_var USER_BASE = get_config_var('userbase') return USER_BASE def getusersitepackages(): """Returns the user-specific site-packages directory path.
🌐
Python
docs.python.org › 3.4 › library › site.html
29.13. site — Site-specific configuration hook — Python 3.4.10 documentation
June 16, 2019 - Return the path of the user-specific site-packages directory, USER_SITE. If it is not initialized yet, this function will also set it, respecting PYTHONNOUSERSITE and USER_BASE. New in version 3.2. The site module also provides a way to get the user directories from the command line:
🌐
Python.org
discuss.python.org › packaging
Understanding site-packages directories - Packaging - Discussions on Python.org
January 7, 2022 - I’m a developer for the Spack package manager. Spack is similar to Conda in the sense that it can install both Python and non-Python libraries, and similar to Nix in the sense that each package is installed to a unique installation prefix. Spack supports reusing system installations of Python (built with apt, yum, conda, etc.). When dealing with Python installations, we’ve noticed that third-party Python libraries may be installed in one of several directories: lib/pythonX.Y/site-packages on...
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › find the location of python site-packages directory
Find the Location of Python site-packages Directory - Spark By {Examples}
May 31, 2024 - How do I find the location of my Python site-packages directory? The "site-packages" directory is where third-party packages are installed for Python. In
🌐
YouTube
youtube.com › watch
How to find the location of Python site-packages directory - YouTube
How to find the location of Python site-packages directory
Published: May 11, 2019