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

Dave Hirschfeld dave.hirschfeld at gmail.com
Mon Jul 11 12:34:31 CEST 2011

Øystein Skotheim <oystein+pythondotnet at ...> writes:

> 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
> <snip>
> 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?
> Cheers,
> ---
> Øystein Skotheim
> Research Scientist, Optical Measurement Systems and Data Analysis
> SINTEF ICT, Trondheim, Norway

Sounds like you may have forgotten to edit your buildclrmodule.bat file to 
reference the .NET4 version of ilasm - see:


I don't know that copying over the newly compiled python.exe will work (possibly
for the reasons you state) however simply copying over the clr.pyd and
Python.Runtime.dll to your C:\Python26 directory should work if you make the
changes to the buildclrmodule.bat file.


More information about the PythonDotNet mailing list