The way the python path is initialized with the embeddable python distribution makes no sense for me. If no environment variable PYTHONPATH is set, then the path is initialized like this: [python352]\python35.zip;.\DLLs;.\lib;[folder_of_executable] --> the distribution folder itself is not in the path ([python352]), an import of _socket will thus fail ! --> Having DLLs and lib in the path is useless (Notice, that when the PYTHONHOME is initialized, then the path '[python352]' is also used for DLLs and lib (instead of '.\') If the environment variable PYTHONPATH is set, then the path is extended like this: [python352]\python35.zip;[folder_of_executable] --> the distribution folder itself is not in the path ([python352]), an import of _socket will thus fail ! I would prefer this behavior: * python path is not initialized anymore with 'DLLs' and 'lib' * the distribution-folder should always be added to the python-path
Environment variables shouldn't make any different to the embeddable distro - it is designed to ignore them. Have you modified it at all? The path is not as clean as I'd like it to be, but the initialization changes necessary are too significant for 3.5 at this stage (expect something better for 3.6).
It looks like you haven't copied pyvenv.cfg to your application directory, so Python isn't using the "applocal" configuration. That's why you're seeing the default paths that are relative to the current directory. It's also why PYTHONPATH and PYTHONHOME aren't ignored. As to the extension modules, if you don't want them in the application directory, add them to the DLLs subdirectory. Here's a possible layout: App\ DLLs\ _socket.pyd ... Lib\ vendored_package ... app.exe pyvenv.cfg python35.dll python35.zip vcruntime140.dll I created this app in C:\Temp, and here's its sys.path: ['C:\\Temp\\App\\python35.zip', 'C:\\Temp\\App\\DLLs', 'C:\\Temp\\App\\lib', 'C:\\Temp\\App']