From oleksii.bidiuk at gmail.com Tue Feb 8 10:13:08 2011 From: oleksii.bidiuk at gmail.com (Oleksii Bidiuk) Date: Tue, 8 Feb 2011 10:13:08 +0100 Subject: [Python.NET] Operator overloading for managed objects In-Reply-To: References: Message-ID: Hi All, I am sorry for repeating the question, but I would like to make sure I am not overlooking something here. Is this a known limitation that the operators overloaded in C# are not working from CPython? So far I had written CPython wrappers for the .NET objects that provide proper operators implementation which is then redirected to explicit C# calls. While this provides 'native' CPython experience and gives additional control over the API exposed to a script (to some extend), it results in extra work, which is mostly a problem on the long term when both C# and Python equivalents have to be maintained in parallel. did anybody have experience with using overloaded operators for managed > objects? I have a class that have e.g. the operator+ overloaded in C#, but > that does not seem to be picked up from the Python side. I have tried to add > overloading using the setattr(MyType, "name", method_name), but it only seem > to work for the native Python objects and not for the managed objects. In > both cases I get "TypeError: unsupported operand type(s) for +: 'MyType' and > 'MyType'". > > Thanks in advance! -- oleksii -------------- next part -------------- An HTML attachment was scrubbed... URL: From jonkersbart at gmail.com Tue Feb 8 10:55:11 2011 From: jonkersbart at gmail.com (Bart Jonkers) Date: Tue, 8 Feb 2011 10:55:11 +0100 Subject: [Python.NET] Python.NET and VS2010/.NET 4.0 Message-ID: Hi, I followed the instructions from oleskii to build Python.NET for .NET4.0. 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 "", line 1, in SystemError: dynamic module not initialized properly >>> Regards, Bart From oleksii.bidiuk at gmail.com Tue Feb 8 11:08:01 2011 From: oleksii.bidiuk at gmail.com (Oleksii Bidiuk) Date: Tue, 8 Feb 2011 11:08:01 +0100 Subject: [Python.NET] Python.NET and VS2010/.NET 4.0 In-Reply-To: References: Message-ID: Hi Bart, the python26.dll is installed to the c:\windows\system32\ folder regardless 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 take the python26.dll along. Check if you have the python26.dll in place and make sure you use the newly built python.exe interpreter. It is indeed recommended to use the python.exe compiled with PythonNET as it does some additional initialization (see the implementation of the Initialize() method in pythonengine.cs code). 2011/2/8 Bart Jonkers > Hi, > > I followed the instructions from oleskii to build Python.NET for .NET4.0. > 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 "", line 1, in > 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... URL: From jonkersbart at gmail.com Tue Feb 8 11:33:36 2011 From: jonkersbart at gmail.com (Bart Jonkers) Date: Tue, 8 Feb 2011 11:33:36 +0100 Subject: [Python.NET] Python.NET and VS2010/.NET 4.0 In-Reply-To: References: Message-ID: Hi Oleskii, Thanks for the quick response. I searched on my system for the python26.dll and I found it in C:\Windows\SysWOW64. I copied it to c:\windows\system32\ and now I'm getting the following error: Unhandled Exception: System.BadImageFormatException: An attempt was made to load 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. Regards, Bart On Tue, Feb 8, 2011 at 11:08 AM, Oleksii Bidiuk wrote: > Hi Bart, > the python26.dll is installed to the c:\windows\system32\ folder regardless > 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 take > the python26.dll along. Check if you have the python26.dll in place and make > sure you use the newly built python.exe interpreter. > > It is indeed recommended to use the python.exe compiled with PythonNET as it > does some additional initialization (see the implementation of the > Initialize() method in pythonengine.cs code). > 2011/2/8 Bart Jonkers >> >> Hi, >> >> I followed the instructions from oleskii to build Python.NET for .NET4.0. >> 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 "", line 1, in >> SystemError: dynamic module not initialized properly >> >>> >> >> Regards, >> Bart >> _________________________________________________ >> Python.NET mailing list - PythonDotNet at python.org >> http://mail.python.org/mailman/listinfo/pythondotnet > > > > -- > oleksii > From oleksii.bidiuk at gmail.com Tue Feb 8 14:34:14 2011 From: oleksii.bidiuk at gmail.com (Oleksii Bidiuk) Date: Tue, 8 Feb 2011 14:34:14 +0100 Subject: [Python.NET] Python.NET and VS2010/.NET 4.0 In-Reply-To: References: Message-ID: Hi Bart, 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 This will make sure the 4.0 is loaded (search on useLegacyV2RuntimeActivationPolicy for more info, normally 2.0 will be loaded). If the above does not help here are a few questions that may point further direction: - 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 installed? - 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 reasonably fast. 2011/2/8 Bart Jonkers > Hi Oleskii, > > Thanks for the quick response. > > I searched on my system for the python26.dll and I found it in > C:\Windows\SysWOW64. > I copied it to c:\windows\system32\ and now I'm getting the following > error: > > Unhandled Exception: System.BadImageFormatException: An attempt was made to > load > 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. > > Regards, > Bart > > On Tue, Feb 8, 2011 at 11:08 AM, Oleksii Bidiuk > wrote: > > Hi Bart, > > the python26.dll is installed to the c:\windows\system32\ folder > regardless > > 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 > take > > the python26.dll along. Check if you have the python26.dll in place and > make > > sure you use the newly built python.exe interpreter. > > > > It is indeed recommended to use the python.exe compiled with PythonNET as > it > > does some additional initialization (see the implementation of the > > Initialize() method in pythonengine.cs code). > > 2011/2/8 Bart Jonkers > >> > >> Hi, > >> > >> I followed the instructions from oleskii to build Python.NET for > .NET4.0. > >> 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 "", line 1, in > >> SystemError: dynamic module not initialized properly > >> >>> > >> > >> Regards, > >> Bart > >> _________________________________________________ > >> Python.NET mailing list - PythonDotNet at python.org > >> http://mail.python.org/mailman/listinfo/pythondotnet > > > > > > > > -- > > oleksii > > > -- oleksii -------------- next part -------------- An HTML attachment was scrubbed... URL: From jonkersbart at gmail.com Tue Feb 8 16:21:41 2011 From: jonkersbart at gmail.com (Bart Jonkers) Date: Tue, 8 Feb 2011 16:21:41 +0100 Subject: [Python.NET] Python.NET and VS2010/.NET 4.0 In-Reply-To: References: Message-ID: Hi Oleskii, I was able to solve the issue. I had to change the Platform target to x86 instead of Any CPU for every project in the solution. It seems that Any CPU will result in an executable that will run as 64-bit application on a 64-bit system and as 32-bit on a 32-bit system. As I have a 64-bit system and have the 32-bit version of python installed it will not load the python dll. By forcing a 32 - bit build the python executable was able to load the python dll. Thanks for your support, Bart On Tue, Feb 8, 2011 at 2:34 PM, Oleksii Bidiuk wrote: > Hi Bart, > > 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 > > > > > > > This will make sure the 4.0 is loaded (search > on?useLegacyV2RuntimeActivationPolicy for more info, normally 2.0 will be > loaded). > If the above does not help?here are a few questions that may point further > direction: > - 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 > installed? > - 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 > reasonably fast. > 2011/2/8 Bart Jonkers >> >> Hi Oleskii, >> >> Thanks for the quick response. >> >> I searched on my system for the python26.dll and I found it in >> C:\Windows\SysWOW64. >> I copied it to c:\windows\system32\ and now I'm getting the following >> error: >> >> Unhandled Exception: System.BadImageFormatException: An attempt was made >> to load >> ?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. >> >> Regards, >> Bart >> >> On Tue, Feb 8, 2011 at 11:08 AM, Oleksii Bidiuk >> wrote: >> > Hi Bart, >> > the python26.dll is installed to the c:\windows\system32\ folder >> > regardless >> > 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 >> > take >> > the python26.dll along. Check if you have the python26.dll in place and >> > make >> > sure you use the newly built python.exe interpreter. >> > >> > It is indeed recommended to use the python.exe compiled with PythonNET >> > as it >> > does some additional initialization (see the implementation of the >> > Initialize() method in pythonengine.cs code). >> > 2011/2/8 Bart Jonkers >> >> >> >> Hi, >> >> >> >> I followed the instructions from oleskii to build Python.NET for >> >> .NET4.0. >> >> 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 "", line 1, in >> >> SystemError: dynamic module not initialized properly >> >> >>> >> >> >> >> Regards, >> >> Bart >> >> _________________________________________________ >> >> Python.NET mailing list - PythonDotNet at python.org >> >> http://mail.python.org/mailman/listinfo/pythondotnet >> > >> > >> > >> > -- >> > oleksii >> > > > > > -- > oleksii > From oleksii.bidiuk at gmail.com Tue Feb 8 16:50:01 2011 From: oleksii.bidiuk at gmail.com (Oleksii Bidiuk) Date: Tue, 8 Feb 2011 16:50:01 +0100 Subject: [Python.NET] Python.NET and VS2010/.NET 4.0 In-Reply-To: References: Message-ID: Hi Bart, thanks for sharing the results! Indeed, you have to make sure the complete stack is compiled for the same platform. I hope this will help other people as well! 2011/2/8 Bart Jonkers > Hi Oleskii, > > I was able to solve the issue. > > I had to change the Platform target to x86 instead of Any CPU for > every project in the solution. > > It seems that Any CPU will result in an executable that will run as > 64-bit application on a 64-bit system and as 32-bit on a 32-bit > system. > As I have a 64-bit system and have the 32-bit version of python > installed it will not load the python dll. > > By forcing a 32 - bit build the python executable was able to load the > python dll. > > Thanks for your support, > Bart > > On Tue, Feb 8, 2011 at 2:34 PM, Oleksii Bidiuk > wrote: > > Hi Bart, > > > > 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 > > > > > > > > > > > > > > This will make sure the 4.0 is loaded (search > > on useLegacyV2RuntimeActivationPolicy for more info, normally 2.0 will be > > loaded). > > If the above does not help here are a few questions that may point > further > > direction: > > - 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 > > installed? > > - 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 > > reasonably fast. > > 2011/2/8 Bart Jonkers > >> > >> Hi Oleskii, > >> > >> Thanks for the quick response. > >> > >> I searched on my system for the python26.dll and I found it in > >> C:\Windows\SysWOW64. > >> I copied it to c:\windows\system32\ and now I'm getting the following > >> error: > >> > >> Unhandled Exception: System.BadImageFormatException: An attempt was made > >> to load > >> 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. > >> > >> Regards, > >> Bart > >> > >> On Tue, Feb 8, 2011 at 11:08 AM, Oleksii Bidiuk > >> wrote: > >> > Hi Bart, > >> > the python26.dll is installed to the c:\windows\system32\ folder > >> > regardless > >> > 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 > >> > take > >> > the python26.dll along. Check if you have the python26.dll in place > and > >> > make > >> > sure you use the newly built python.exe interpreter. > >> > > >> > It is indeed recommended to use the python.exe compiled with PythonNET > >> > as it > >> > does some additional initialization (see the implementation of the > >> > Initialize() method in pythonengine.cs code). > >> > 2011/2/8 Bart Jonkers > >> >> > >> >> Hi, > >> >> > >> >> I followed the instructions from oleskii to build Python.NET for > >> >> .NET4.0. > >> >> 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 "", line 1, in > >> >> SystemError: dynamic module not initialized properly > >> >> >>> > >> >> > >> >> Regards, > >> >> Bart > >> >> _________________________________________________ > >> >> Python.NET mailing list - PythonDotNet at python.org > >> >> http://mail.python.org/mailman/listinfo/pythondotnet > >> > > >> > > >> > > >> > -- > >> > oleksii > >> > > > > > > > > > -- > > oleksii > > > -- oleksii -------------- next part -------------- An HTML attachment was scrubbed... URL: From btribble at ea.com Tue Feb 8 22:10:50 2011 From: btribble at ea.com (Tribble, Brett) Date: Tue, 8 Feb 2011 13:10:50 -0800 Subject: [Python.NET] Python.NET and VS2010/.NET 4.0 In-Reply-To: References: Message-ID: Has anyone been able to get this working on Windows 7 as 64 bit ?all the way down?? I?m about to have this thrown on my plate I think? From: pythondotnet-bounces+btribble=ea.com at python.org [mailto:pythondotnet-bounces+btribble=ea.com at python.org] On Behalf Of Oleksii Bidiuk Sent: Tuesday, February 08, 2011 7:50 AM To: Bart Jonkers Cc: pythondotnet at python.org Subject: Re: [Python.NET] Python.NET and VS2010/.NET 4.0 Hi Bart, thanks for sharing the results! Indeed, you have to make sure the complete stack is compiled for the same platform. I hope this will help other people as well! 2011/2/8 Bart Jonkers > Hi Oleskii, I was able to solve the issue. I had to change the Platform target to x86 instead of Any CPU for every project in the solution. It seems that Any CPU will result in an executable that will run as 64-bit application on a 64-bit system and as 32-bit on a 32-bit system. As I have a 64-bit system and have the 32-bit version of python installed it will not load the python dll. By forcing a 32 - bit build the python executable was able to load the python dll. Thanks for your support, Bart On Tue, Feb 8, 2011 at 2:34 PM, Oleksii Bidiuk > wrote: > Hi Bart, > > 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 > > > > > > > This will make sure the 4.0 is loaded (search > on useLegacyV2RuntimeActivationPolicy for more info, normally 2.0 will be > loaded). > If the above does not help here are a few questions that may point further > direction: > - 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 > installed? > - 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 > reasonably fast. > 2011/2/8 Bart Jonkers > >> >> Hi Oleskii, >> >> Thanks for the quick response. >> >> I searched on my system for the python26.dll and I found it in >> C:\Windows\SysWOW64. >> I copied it to c:\windows\system32\ and now I'm getting the following >> error: >> >> Unhandled Exception: System.BadImageFormatException: An attempt was made >> to load >> 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. >> >> Regards, >> Bart >> >> On Tue, Feb 8, 2011 at 11:08 AM, Oleksii Bidiuk >> > wrote: >> > Hi Bart, >> > the python26.dll is installed to the c:\windows\system32\ folder >> > regardless >> > 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 >> > take >> > the python26.dll along. Check if you have the python26.dll in place and >> > make >> > sure you use the newly built python.exe interpreter. >> > >> > It is indeed recommended to use the python.exe compiled with PythonNET >> > as it >> > does some additional initialization (see the implementation of the >> > Initialize() method in pythonengine.cs code). >> > 2011/2/8 Bart Jonkers > >> >> >> >> Hi, >> >> >> >> I followed the instructions from oleskii to build Python.NET for >> >> .NET4.0. >> >> 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 "", line 1, in >> >> SystemError: dynamic module not initialized properly >> >> >>> >> >> >> >> Regards, >> >> Bart >> >> _________________________________________________ >> >> Python.NET mailing list - PythonDotNet at python.org >> >> http://mail.python.org/mailman/listinfo/pythondotnet >> > >> > >> > >> > -- >> > oleksii >> > > > > > -- > oleksii > -- oleksii -------------- next part -------------- An HTML attachment was scrubbed... URL: From oleksii.bidiuk at gmail.com Wed Feb 9 12:03:12 2011 From: oleksii.bidiuk at gmail.com (Oleksii Bidiuk) Date: Wed, 9 Feb 2011 12:03:12 +0100 Subject: [Python.NET] Multiple Initialize, RunSimpleString, Shutdown calls result in AccessViolationException Message-ID: Hi All, I am seeing weird problems with embedding PythonNET/Python 2.6 in a C#, using 4.0 runtime application built with VS2010 on Windows XP SP3. Design outline -------------------- For every script I execute the following sequence on a separate thread (does not seem to matter the same or different one every time) to avoid blocking GUI: PythonEngine.Initialize(); IntPtr pythonLock = PythonEngine.AcquireLock(); PythonEngine.RunSimpleString(source); PythonEngine.ReleaseLock(pythonLock); PythonEngine.Shutdown(); I use the RunSimpleString() as the RunString() didn't work for me (always returns NULL and does not execute the code, suggestions welcome!). Problem description ----------------------------- Running simple scripts like 'print "whatever"' goes well. I can run scripts multiple (>10) times without any side-effects. Problems start when importing certain modules (like ctypes, numpy), or accessing collections of .NET objects returned by the .NET API. For example, the following scripts will fail executing SECOND time. Whenever I call the script AGAIN I get AccessViolationException or even ExecutionEngineException (with debugger attached of course) in the Shutdown() call. Example 1 --------------- import ctypes Exampe 2 -------------- import clr clr.AddReference("System.Drawing") import System.Drawing bmp = System.Drawing.Bitmap("c:\\image.bmp") I should be doing something completely wrong, but I just cannot see it... Please help! -- oleksii -------------- next part -------------- An HTML attachment was scrubbed... URL: From Sharon.Rozenblum at sandisk.com Thu Feb 10 12:48:08 2011 From: Sharon.Rozenblum at sandisk.com (Sharon Rozenblum) Date: Thu, 10 Feb 2011 13:48:08 +0200 Subject: [Python.NET] Setting PYTHONPATH from code Message-ID: Hi! Can someone tell me how to set PYTHONPATH variable in code when working with Python.Runtime.dll without changing the value in the system variables before. Thanks SHARON ________________________________ PLEASE NOTE: The information contained in this electronic mail message is intended only for the use of the designated recipient(s) named above. If the reader of this message is not the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify the sender by telephone or e-mail (as shown above) immediately and destroy any and all copies of this message in your possession (whether hard copies or electronically stored copies). -------------- next part -------------- An HTML attachment was scrubbed... URL: From oleksii.bidiuk at gmail.com Thu Feb 10 13:20:54 2011 From: oleksii.bidiuk at gmail.com (Oleksii Bidiuk) Date: Thu, 10 Feb 2011 13:20:54 +0100 Subject: [Python.NET] Setting PYTHONPATH from code In-Reply-To: References: Message-ID: Hi Sharon, What do you want to achieve with this? If you want to provide path for loading your own modules you can change the sys.path value by e.g. running a 'initialization' script with import sys sys.path.insert(0, 'your/own/path') You can build up the script above in C# by inserting the path you need and then performing e.g. RunSimpleString(