Author AlexWMF
Recipients AlexWMF
Date 2016-05-11.11:00:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1462964428.89.0.669222260806.issue26998@psf.upfronthosting.co.za>
In-reply-to
Content
Unable to import "site" error occurs in an embedded application.
I have made small research and found why this module isn't visible for python core.

I have run the python 2.7.11 x86 (for all users) at my win 7x64.
The installer writes the registry key "Software\Wow6432Node\Python\PythonCore\%s\", where "%s" is equal to "32" on my machine.
Difference between x86 and x86_64 registry keys is only in "Wow6432Node" subkey in that key path. 
Tracing the application, I have got to getpythonregpath(...) function. This function reads the registry key to determine "PythonPath".
The python core tries to open the following key "Software\Wow6432Node\Python\PythonCore\2.7-32\PythonPath" and fails due to absence of that key.

In this case, the DLL was compiled with PyWin_DLLVersionString = "2.7-32".
Because of this, the python core can't open this key and the "sys.path" stays not fully filled with paths from registry.

The PyWin_DLLVersionString is compiles from MS_DLL_ID="$(SysWinVer)", which is equal to "2.7-32" on my system.
It's defined in .\PCbuild\python.props file as 
<SysWinVer>$(MajorVersionNumber).$(MinorVersionNumber)</SysWinVer>
<SysWinVer Condition="$(Platform) == 'Win32' or $(Platform) == 'x86'">$(SysWinVer)-32</SysWinVer>

So, the simplest solution of this bug is to fix installer to store proper key
History
Date User Action Args
2016-05-11 11:00:28AlexWMFsetrecipients: + AlexWMF
2016-05-11 11:00:28AlexWMFsetmessageid: <1462964428.89.0.669222260806.issue26998@psf.upfronthosting.co.za>
2016-05-11 11:00:28AlexWMFlinkissue26998 messages
2016-05-11 11:00:27AlexWMFcreate