About the PYTHONPATH envvar
PYTHONPATHenvironment variable can be used to add additional directories in front of the default import path. By default it is empty or not set, and the default import path is always added after any locations from
PYTHONPATH. On Pythonista,
PYTHONPATHcontains all locations from the default import path, as if there were no default import locations and all locations were user-defined. It should really be emtpy, because all
sys.pathentries are provided by default, and none of them are set by the user.
Why does this matter?
setuptoolsdoes some magic by installing a custom
site-packages, which needs to find the real
site.pymodule from the stdlib to work correctly. During this search it ignores any import locations from
PYTHONPATH, which includes all import locations on Pythonista, meaning that nothing is searched at all and the import of
On a slightly related note, it looks like
sys.pathis reset every time a script is run (even an editor action) without reloading
siteagain, which means that any previous
.pthfiles) are lost until
siteis manually reloaded.