PythonPath / sys.path

Eryk Sun eryksun at gmail.com
Sun May 14 18:12:52 EDT 2023


On 5/13/23, Grizzy Adams via Python-list <python-list at python.org> wrote:
>
> I have tried adding my dir in registry to the existing PythonPath
>
> [HKEY_CURRENT_USER\Software\Python\PythonCore\3.4\PythonPath]
> @="D:\\Shades\\Tools\\Python\\Lib;D:\\Shades\\Tools\\Python\\DLLs"
>
> that did not help,

The default value of the above registry key is only used if Python
can't calculate the default sys.path based on searching for "os.py",
the landmark module in the standard library. This can happen sometimes
when Python is embedded or run from a symlink.

The default value of each subkey of
"[HKCU|HKLM]\Software\Python\PythonCore\<version>\PythonPath", on the
other hand, usually does extend sys.path. Except that running Python
with the -E or -I command-line options (both supported by Python 3.4)
makes the interpreter ignore PYTHON* environment variables, including
PYTHONPATH, as well as registry settings such as subkeys of
"PythonPath".

Even with the -E or -I command-line options, .pth files in the system
site-packages are still processed. A .pth file can be used to extend
sys.path as long as the site module is imported, i.e. as long as the
-S command-line option isn't used. One difference, however, is that
directories in .pth files are appended to sys.path and thus do not
override the standard library.


More information about the Python-list mailing list