This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Embeddable Python does not use PYTHONPATH.
Type: Stage: resolved
Components: Windows Versions: Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Jarno Rajala, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2016-09-22 05:57 by Jarno Rajala, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg277192 - (view) Author: Jarno Rajala (Jarno Rajala) Date: 2016-09-22 05:57
The Windows 64-bit embeddable Python 3.5.2 (also 3.5.1), downloadable from
https://www.python.org/ftp/python/3.5.2/python-3.5.2-embed-amd64.zip, does not set sys.path according to PYTHONPATH.

To reproduce this bug, run these commands from the directory with the embeddable package:
set PYTHONPATH=dummy
python
import sys;sys.path

If this is deliberate behaviour, the help message (python --help) should say that PYTHONPATH doesn't apply, instead it has the usual message. Also, there should be an alternate way of setting additional sys.path directories, e.g. with an additional command-line option. Currently, there's no way to change sys.path, except from Python itself.
msg277202 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2016-09-22 07:05
See https://docs.python.org/3/using/windows.html#embedded-distribution - "When extracted, the embedded distribution is (almost) fully isolated from the user’s system, including environment variables, system registry settings, and installed packages."

This is deliberate behaviour. The embedded distribution is intended for, as it says, embedded applications, and your C code that embeds the Python interpreter can set sys.path based on application-specific environment variables if needed. But it should not be affected by any "normal" Python configuration.
msg277223 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2016-09-22 13:44
Correct, and if you look ahead to 3.6 then you'll see I've already changed how this works. There is now support for a python._pth file that contains exactly the paths you want in sys.path, as well as suppressing all other sources.
History
Date User Action Args
2022-04-11 14:58:37adminsetgithub: 72432
2016-09-22 13:44:21steve.dowersetstatus: open -> closed
resolution: not a bug
messages: + msg277223

stage: resolved
2016-09-22 07:05:13paul.mooresetmessages: + msg277202
2016-09-22 05:57:05Jarno Rajalacreate