-
site
modulesite.py
as a module is automatically imported during initialization.The automatic import can be supressed using the interpreter’s
-S
option.Importing this module will append site-specific paths to the module search path and add a few builtins.
-
site-packages
There are two types of
site-packages
directories, global and per user:-
Global
site-packages
directories are listed insys.path
when you runA directory in
sys.path
. In contrast to ordinary directories the pth files in the directory are processed, too.python -m site
For a more concise list run getsitepackages from the site module in Python code:
python -c "import site; print(site.getsitepackages())" python3 -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])'
关于
python -c
参见:默认路径:
- Windows
prefix\Lib\site-packages
- Unix(pure)
prefix/lib/pythonX.Y/site-packages
- Unix(non-pure)
exec-prefix/lib/pythonX.Y/site-packages
- Windows
-
The per user
site-packages
directory (PEP 370) is where Python installs your local packagesA site directory inside the user’s home directory.
A user site directory is specific to a Python version. The path contains the verison number(major and minor only)
python -m site --user-site
pip list --user
list all installed per user site-packages.- Unix
~/.local/lib/pythonX.Y/site-packages
- Windows
%APPDATA%/Python/Python26/site-packages
- Unix
site-packages
is the location where 3rd party packages are installed.(On Linux you have to be root to write to it)pure means that the module uses only Python code.
Non-pure can contain C/C++ code as well.
-
-
References
理解site,site-packages in Python
最新推荐文章于 2024-04-22 16:07:30 发布