Re: [Python.NET] Using Third Party C# Libraries
![](https://secure.gravatar.com/avatar/01ff10d25e784c06d0a60d39e05caae6.jpg?s=120&d=mm&r=g)
Haven't seen this before. Sorry. Do you have .NET 2.0 installed on your machine? -----Original Message----- From: Chris Spencer [mailto:chrisspen@gmail.com] Sent: Tuesday, February 20, 2007 12:59 PM To: Maksim Kozyarchuk Cc: pythondotnet@python.org Subject: Re: [Python.NET] Using Third Party C# Libraries I've copied SharpNeatLib.dll to C:\Program Files\PythonNet, C:\Program Files\PythonNet\Lib, C:\Program Files\PythonNet\Lib\site-packages, C:\Program Files\Python24, C:\Program Files\Python24\Lib, and C:\Program Files\Python24\Lib\site-packages but it still raises that exception "ImportError: cannot import name SharpNeatLib". Using Assembly.Load("SharpNeatLib.dll") raises a different exception:
Assembly.Load('SharpNeatLib.dll') Traceback (most recent call last): File "<stdin>", line 1, in ? CLR.System.BadImageFormatException: Version 2.0 is not a compatible version. at System.Reflection.Assembly.nLoadImage(Byte[] rawAssembly, Byte[] rawSymbol Store, Evidence evidence, StackCrawlMark& stackMark) at System.Reflection.Assembly.Load(Byte[] rawAssembly)
Would this indicate that the SharpNeatLib.dll was built with a C# compiler incompatible with what Python.Net was built with? Chris On 2/20/07, Maksim Kozyarchuk <mkozyarchuk@funddevelopmentservices.com> wrote:
Yes. The Assembly would be SharpNeatLib, in order for this to work you need to place SharpNeatLib.dll into your PYTHON_PATH or the GAC.
import CLR from CLR.System.Reflection import Assembly Assembly.LoadWithPartialName('SharpNeatLib') from CLR.Name.Space import ClassName
Maksim
-----Original Message----- From: Chris Spencer [mailto:chrisspen@gmail.com] Sent: Tuesday, February 20, 2007 12:14 PM To: Maksim Kozyarchuk Cc: pythondotnet@python.org Subject: Re: [Python.NET] Using Third Party C# Libraries
I'm assuming you meant I have to replace 'TheAssembly' with some variation of SharpNeatLib.dll. Could you please be more specific? It doesn't seem to work for any combination.
import CLR from CLR.System.Reflection import Assembly Assembly.LoadWithPartialName('SharpNeatLib') import CLR.SharpNeatLib Traceback (most recent call last): File "<stdin>", line 1, in ? ImportError: No module named SharpNeatLib
import CLR from CLR.System.Reflection import Assembly Assembly.LoadWithPartialName('SharpNeatLib.dll') import CLR.SharpNeatLib Traceback (most recent call last): File "<stdin>", line 1, in ? ImportError: No module named SharpNeatLib
import CLR from CLR.System.Reflection import Assembly Assembly.LoadWithPartialName('SharpNeat') import CLR.SharpNeat Traceback (most recent call last): File "<stdin>", line 1, in ? ImportError: No module named SharpNeat
Regards, Chris
On 2/20/07, Maksim Kozyarchuk
<mkozyarchuk@funddevelopmentservices.com>
wrote:
Try the following syntax.
import CLR from CLR.System.Reflection import Assembly Assembly.LoadWithPartialName('TheAssebly') from CLR.Name.Space import ClassName
-----Original Message----- From: pythondotnet-bounces@python.org [mailto:pythondotnet-bounces@python.org] On Behalf Of Chris Spencer Sent: Tuesday, February 20, 2007 11:55 AM To: pythondotnet@python.org Subject: [Python.NET] Using Third Party C# Libraries
Hi,
I'm new to Python.Net, and I'd like to access a C# library (SharpNeat) from Python. I tried placing it's DLL (SharpNeatLib.dll) into C:\Program Files\PythonNet\Lib\site-packages but when I try to import it I get the error:
import SharpNeatLib Traceback (most recent call last): File "<stdin>", line 1, in ? ImportError: dynamic module does not define init function (initSharpNeatLib)
Is there something I'm doing wrong? Any help is appreciated.
Thanks, Chris _________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet
![](https://secure.gravatar.com/avatar/c125f576c3a08c0c1d4330bc565ae28c.jpg?s=120&d=mm&r=g)
Yes, I have the .NET Framework SDK for both 1.1 and 2.0 installed. On 2/20/07, Maksim Kozyarchuk <mkozyarchuk@funddevelopmentservices.com> wrote:
Haven't seen this before. Sorry.
Do you have .NET 2.0 installed on your machine?
-----Original Message----- From: Chris Spencer [mailto:chrisspen@gmail.com] Sent: Tuesday, February 20, 2007 12:59 PM To: Maksim Kozyarchuk Cc: pythondotnet@python.org Subject: Re: [Python.NET] Using Third Party C# Libraries
I've copied SharpNeatLib.dll to C:\Program Files\PythonNet, C:\Program Files\PythonNet\Lib, C:\Program Files\PythonNet\Lib\site-packages, C:\Program Files\Python24, C:\Program Files\Python24\Lib, and C:\Program Files\Python24\Lib\site-packages but it still raises that exception "ImportError: cannot import name SharpNeatLib".
Using Assembly.Load("SharpNeatLib.dll") raises a different exception:
Assembly.Load('SharpNeatLib.dll') Traceback (most recent call last): File "<stdin>", line 1, in ? CLR.System.BadImageFormatException: Version 2.0 is not a compatible version. at System.Reflection.Assembly.nLoadImage(Byte[] rawAssembly, Byte[] rawSymbol Store, Evidence evidence, StackCrawlMark& stackMark) at System.Reflection.Assembly.Load(Byte[] rawAssembly)
Would this indicate that the SharpNeatLib.dll was built with a C# compiler incompatible with what Python.Net was built with?
Chris
participants (2)
-
Chris Spencer
-
Maksim Kozyarchuk