I'm using Cython in --embed
mode to produce a .exe. I'm evaluating the Minimal set of files required to distribute an embed-Cython-compiled code and make it work on any machine. To do this, I only copy a minimal number of files from the Python Windows embeddable package.
In order to check this, I need to be sure that the current process I'm testing doesn't in fact use my system default Python install, i.e. C:\Python38.
To do this, I open a new cmd.exe
and do set PATH=
which temporarily removes everything from the PATH. Then I can test any self-compiled app.exe
and make sure it doesn't reuse C:\Python38
's files under the hood.
It works, except for the modules. Even after doing set PATH=
, my code app.py
import json
print(json.dumps({"a":"b"}))
when Cython---embed
-compiled into a .exe works, but it still uses C:\Python38\Lib\json\__init__.py
! I know this for sure, because if I temporarily remove this file, my .exe now fails, because it cannot find the json
module.
How to completely remove any link to C:\Python38
when debugging a Python program which shouldn't use these files?
Why isn't set PATH=
enough? Which other environment variable does it use for modules? I checked all my system variables and I think I don't find any which seems related to Python.
PATH
has to do with where Windows looks for exes. It has nothing to do with where Python looks for modules – TaraxacumC:\Python38
folder? Is there a Windows registry key that informs about this, or another environment variable? – Africa