Python site Module
Example
Display site-specific directories and user base:
import site
print(f'User site packages: {site.USER_SITE}')
print(f'User base: {site.USER_BASE}')
Try it Yourself »
Definition and Usage
The site module automatically runs at Python startup to configure site-specific paths and settings.
Use it to query or modify Python's module search paths, user site directories, or custom site configurations.
Members
Member | Description |
---|---|
ENABLE_USER_SITE | Flag indicating if user site-packages directory is enabled. |
USER_BASE | Path to user base directory for installations. |
USER_SITE | Path to user site-packages directory. |
addsitedir() | Add a directory to sys.path and process .pth files. |
getsitepackages() | Return a list of site-packages directories. |
getuserbase() | Return the user base directory path. |
getusersitepackages() | Return the user site-packages directory path. |