[Python.NET] Replaced Python.exe file causes problems for extension modules

Øystein Skotheim oystein+pythondotnet at edge.no
Mon Jul 11 11:58:28 CEST 2011

Hello. I have managed to compile the SVN version of PythonDotNet against 
the 4.0 version of the .NET library with Visual Studio 2010 on Windows 
7. I copied over clr.pyd, Python.Runtime.dll as well as new versions of 
python.exe and pythonw.exe into my C:\Python26 directory. I am now able 
to import .NET 4.0 modules after writing "import clr" :-)

However, I have run into a few problems because I had to replace my 
Python executable. I am using a lot of packages from the PythonXY that 
depend on c extension modules (.pyd-files). Whenever I try to import 
such a module, I get the following error:

Runtime Error!

Program: C:\Python26\Python.exe

An application has made an attempt to load the C runtime library 
Please contact the application's support team for more information.

I think the reason for this is that I have compiled Python.exe with 
Visual Studio 2010, whereas the extension modules are compiled with 
Visual Studio 2008 (i.e. my Python.exe is linked against msvcrt10.dll 
while the extension modules are linked against msvcrt90.dll)

Is there any way I can prevent this error from happening without having 
to recompile all the extension modules in my PythonXY distribution?

The other solution would be to keep my original "Python.exe" file, but 
if I do that I get the following error message when I try to import the 
CLR module:

In [1]: import clr
Traceback (most recent call last):
   File "<ipython console>", line 1, in <module>
SystemError: dynamic module not initialized properly

Is there any way around this?


Øystein Skotheim
Research Scientist, Optical Measurement Systems and Data Analysis
SINTEF ICT, Trondheim, Norway

More information about the PythonDotNet mailing list