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.
๐ŸŒ
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?
๐ŸŒ
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.
Find elsewhere
๐ŸŒ
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 ']
๐ŸŒ
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
๐ŸŒ
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.
๐ŸŒ
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
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