Hi Bart,<br><br><div>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</div>
<div><br></div><div><div>&lt;?xml version=&quot;1.0&quot;?&gt;</div><div>&lt;configuration&gt;</div><div>&lt;startup useLegacyV2RuntimeActivationPolicy=&quot;true&quot;&gt;</div><div>&lt;supportedRuntime version=&quot;v4.0&quot; sku=&quot;.NETFramework,Version=v4.0&quot;/&gt;</div>
<div>&lt;/startup&gt;</div><div>&lt;/configuration&gt;</div></div><div><br></div><div>This will make sure the 4.0 is loaded (search on useLegacyV2RuntimeActivationPolicy for more info, normally 2.0 will be loaded).</div><div>
<br></div><div>If the above does not help here are a few questions that may point further direction: </div><div>- Have you compiled for 32 or 64 bits (there is an .il for 64 bits, but I haven&#39;t tried it myself)? </div>
<div>- Which version of runtime (2.0, 3.0/3.5, 4.0; x32 or x64 bits) do you have installed? </div><div>- Do you start on the same machine where your development environment is started or in a separate environment? </div><div>
<br></div><div>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 reasonably fast. </div>
<div><br><div class="gmail_quote">2011/2/8 Bart Jonkers <span dir="ltr">&lt;<a href="mailto:jonkersbart@gmail.com">jonkersbart@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Oleskii,<br>
<br>
Thanks for the quick response.<br>
<br>
I searched on my system for the python26.dll and I found it in<br>
C:\Windows\SysWOW64.<br>
I copied it to c:\windows\system32\ and now I&#39;m getting the following error:<br>
<br>
Unhandled Exception: System.BadImageFormatException: An attempt was made to load<br>
 a program with an incorrect format. (Exception from HRESULT: 0x8007000B)<br>
<div class="im">   at Python.Runtime.Runtime.Py_Initialize()<br>
   at Python.Runtime.Runtime.Initialize()<br>
   at Python.Runtime.PythonEngine.Initialize()<br>
   at Python.Runtime.PythonConsole.Main(String[] args)<br>
<br>
</div>Anny idea?<br>
<br>
I have installed python 2.6.6 (32-bit) on a 64-bit version of Windows 7.<br>
<br>
The problem that we have with the .NET version of python.exe is that<br>
it takes some time before it starts.<br>
As we use python in our build environment, it significantly slows down<br>
our build process.<br>
<br>
Regards,<br>
<font color="#888888">Bart<br>
</font><div><div></div><div class="h5"><br>
On Tue, Feb 8, 2011 at 11:08 AM, Oleksii Bidiuk<br>
&lt;<a href="mailto:oleksii.bidiuk@gmail.com">oleksii.bidiuk@gmail.com</a>&gt; wrote:<br>
&gt; Hi Bart,<br>
&gt; the python26.dll is installed to the c:\windows\system32\ folder regardless<br>
&gt; of where your main Python installation goes to. I&#39;ve seen similar problem<br>
&gt; when I have copied the Python26 folder to a new machine and forgot to take<br>
&gt; the python26.dll along. Check if you have the python26.dll in place and make<br>
&gt; sure you use the newly built python.exe interpreter.<br>
&gt;<br>
&gt; It is indeed recommended to use the python.exe compiled with PythonNET as it<br>
&gt; does some additional initialization (see the implementation of the<br>
&gt; Initialize() method in pythonengine.cs code).<br>
&gt; 2011/2/8 Bart Jonkers &lt;<a href="mailto:jonkersbart@gmail.com">jonkersbart@gmail.com</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt; Hi,<br>
&gt;&gt;<br>
&gt;&gt; I followed the instructions from oleskii to build Python.NET for .NET4.0.<br>
&gt;&gt; Compilation wend fine but when I try to run python.exe I get the<br>
&gt;&gt; following error:<br>
&gt;&gt;<br>
&gt;&gt; Unhandled Exception: System.DllNotFoundException: Unable to load DLL<br>
&gt;&gt; &#39;python26&#39;:<br>
&gt;&gt;  The specified module could not be found. (Exception from HRESULT:<br>
&gt;&gt; 0x8007007E)<br>
&gt;&gt;   at Python.Runtime.Runtime.Py_Initialize()<br>
&gt;&gt;   at Python.Runtime.Runtime.Initialize()<br>
&gt;&gt;   at Python.Runtime.PythonEngine.Initialize()<br>
&gt;&gt;   at Python.Runtime.PythonConsole.Main(String[] args)<br>
&gt;&gt;<br>
&gt;&gt; I have installed Python in C:\Python26.<br>
&gt;&gt; Does any one an idea?<br>
&gt;&gt;<br>
&gt;&gt; Is it necessary to use the python.exe build by the project or is it<br>
&gt;&gt; also possible to use the original python executable?<br>
&gt;&gt; When I try to use the original python executable I get the following<br>
&gt;&gt; error:<br>
&gt;&gt; Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit<br>
&gt;&gt; (Intel)] on<br>
&gt;&gt; win32<br>
&gt;&gt; Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<br>
&gt;&gt; &gt;&gt;&gt; import clr<br>
&gt;&gt; Traceback (most recent call last):<br>
&gt;&gt;  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;<br>
&gt;&gt; SystemError: dynamic module not initialized properly<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Regards,<br>
&gt;&gt; Bart<br>
&gt;&gt; _________________________________________________<br>
&gt;&gt; Python.NET mailing list - <a href="mailto:PythonDotNet@python.org">PythonDotNet@python.org</a><br>
&gt;&gt; <a href="http://mail.python.org/mailman/listinfo/pythondotnet" target="_blank">http://mail.python.org/mailman/listinfo/pythondotnet</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; oleksii<br>
&gt;<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>oleksii<br>
</div>