[Python.NET] Python.NET and VS2010/.NET 4.0
oleksii.bidiuk at gmail.com
Tue Feb 8 14:34:14 CET 2011
I am no way an expert on this question, but it seem that your PythonNET is
trying to load a different version of runtime than the one he was compiled
against. You need to make sure the same runtime is built and used for
python.exe. To make sure the 4.0 is used, you can create / edit the
python.exe.config file (located in the same folder from where you start the
newly compiled python.exe) with the following contents
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
This will make sure the 4.0 is loaded (search
on useLegacyV2RuntimeActivationPolicy for more info, normally 2.0 will be
If the above does not help here are a few questions that may point further
- Have you compiled for 32 or 64 bits (there is an .il for 64 bits, but I
haven't tried it myself)?
- Which version of runtime (2.0, 3.0/3.5, 4.0; x32 or x64 bits) do you have
- Do you start on the same machine where your development environment is
started or in a separate environment?
Regarding the startup time, do you experience slow start of pythonNET
version one time or every time it is started? I can imagine it is slow the
first time (as it has to load CLR), but the consequent starts have to be
2011/2/8 Bart Jonkers <jonkersbart at gmail.com>
> Hi Oleskii,
> Thanks for the quick response.
> I searched on my system for the python26.dll and I found it in
> I copied it to c:\windows\system32\ and now I'm getting the following
> Unhandled Exception: System.BadImageFormatException: An attempt was made to
> a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
> at Python.Runtime.Runtime.Py_Initialize()
> at Python.Runtime.Runtime.Initialize()
> at Python.Runtime.PythonEngine.Initialize()
> at Python.Runtime.PythonConsole.Main(String args)
> Anny idea?
> I have installed python 2.6.6 (32-bit) on a 64-bit version of Windows 7.
> The problem that we have with the .NET version of python.exe is that
> it takes some time before it starts.
> As we use python in our build environment, it significantly slows down
> our build process.
> On Tue, Feb 8, 2011 at 11:08 AM, Oleksii Bidiuk
> <oleksii.bidiuk at gmail.com> wrote:
> > Hi Bart,
> > the python26.dll is installed to the c:\windows\system32\ folder
> > of where your main Python installation goes to. I've seen similar problem
> > when I have copied the Python26 folder to a new machine and forgot to
> > the python26.dll along. Check if you have the python26.dll in place and
> > sure you use the newly built python.exe interpreter.
> > It is indeed recommended to use the python.exe compiled with PythonNET as
> > does some additional initialization (see the implementation of the
> > Initialize() method in pythonengine.cs code).
> > 2011/2/8 Bart Jonkers <jonkersbart at gmail.com>
> >> Hi,
> >> I followed the instructions from oleskii to build Python.NET for
> >> Compilation wend fine but when I try to run python.exe I get the
> >> following error:
> >> Unhandled Exception: System.DllNotFoundException: Unable to load DLL
> >> 'python26':
> >> The specified module could not be found. (Exception from HRESULT:
> >> 0x8007007E)
> >> at Python.Runtime.Runtime.Py_Initialize()
> >> at Python.Runtime.Runtime.Initialize()
> >> at Python.Runtime.PythonEngine.Initialize()
> >> at Python.Runtime.PythonConsole.Main(String args)
> >> I have installed Python in C:\Python26.
> >> Does any one an idea?
> >> Is it necessary to use the python.exe build by the project or is it
> >> also possible to use the original python executable?
> >> When I try to use the original python executable I get the following
> >> error:
> >> Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit
> >> (Intel)] on
> >> win32
> >> Type "help", "copyright", "credits" or "license" for more information.
> >> >>> import clr
> >> Traceback (most recent call last):
> >> File "<stdin>", line 1, in <module>
> >> SystemError: dynamic module not initialized properly
> >> >>>
> >> Regards,
> >> Bart
> >> _________________________________________________
> >> Python.NET mailing list - PythonDotNet at python.org
> >> http://mail.python.org/mailman/listinfo/pythondotnet
> > --
> > oleksii
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PythonDotNet