Discussion:
[Python.NET] Getting started with Python for .NET
Anneka Boccio
2012-11-06 19:08:59 UTC
Permalink
I'm completely new to Python for .Net, and I actually have very little
experience with Python and no experience with C#. So please forgive me if my
question seems very basic.

I'm using Python 2.7.3, and I downloaded
pythonnet-2.0-alpha2-clr2.0_131_py27_UCS2 and unzipped it into a folder named
pyfornet_test, which also contains the dll I'm trying to use (called
DotNet4Class.dll)

Then I run this:
import sys
import os
import clr
sys.path.append(r"C:\pyfornet_test")
clr.AddReference("DotNet4Class.dll")

Which gives me this error:
System.IO.FileNotFoundException: Unable to find assembly 'DotNet4Class.dll'.
at Python.Runtime.CLRModule.AddReference(String name) in
C:\Users\Barton\Documents\Visual Studio 2008\Projects\PyShar
p\trunk\pythonnet\src\runtime\moduleobject.cs:line 375


Any advice would be much appreciated. Thank you!



_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
http://mail.python.org/mailman/listinfo/pythondotnet
John Burkhart
2012-11-07 13:22:05 UTC
Permalink
Annika,

I too just started with pythonnet. What I'm learning is that the
compilation of pythonnet needs to match that of the .dll you are trying to
load. So, for instance, how was your .dll built (for .NET 4? 3.5? ..).

Check that.

In my case I had to build pythonnet targeted for .NET 4 but it caused many
other problems with underlying imports of pure CPython. I made a recent
post on the issue for IPython:

http://wiki.ipython.org/Cookbook/python.NET

Maybe that will help!
Liam Corrigan
2012-11-07 13:42:18 UTC
Permalink
Received: from localhost (HELO mail.python.org) (127.0.0.1)
by albatross.python.org with SMTP; 07 Nov 2012 14:54:25 +0100
Received: from mail2.allenvanguard.com (mail2.allenvanguard.com
[67.69.224.190])
(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
(No client certificate requested)
by mail.python.org (Postfix) with ESMTPS
for <pythondotnet-+ZN9ApsXKcEdnm+***@public.gmane.org>; Wed, 7 Nov 2012 14:54:25 +0100 (CET)
X-ASG-Debug-ID: 1352295739-5c5925df0001-WobTiC
Received: from srvna-ex01.allenvanguard.local (srvna-ex01.allenvanguard.local
[10.0.33.97]) by mail2.allenvanguard.com with ESMTP id
hPGCnrpFPPAsAQpL (version=TLSv1 cipher=AES128-SHA bits=128
verify=NO) for <pythondotnet-+ZN9ApsXKcEdnm+***@public.gmane.org>; Wed, 07 Nov 2012 08:4
X-Barracuda-Envelope-From: Liam.Corrigan-pQIqDjLNBDebII5o8exnGAC/***@public.gmane.org
X-ASG-Whitelist: Client
Received: from SRVNA-EX02.allenvanguard.local ([fe80::d89:26e6:5f8d:4b67]) by
SRVNA-EX01.allenvanguard.local ([fe80::681f:9acc:d0f1:2347%14]) with
mapi id 14.02.0318.001; Wed, 7 Nov 2012 08:42:19 -0500
X-Barracuda-BBL-IP: fe80::d89:26e6:5f8d:4b67
X-Barracuda-RBL-IP: fe80::d89:26e6:5f8d:4b67
X-ASG-Orig-Subj: RE: Getting started with Python for .NET
Thread-Topic: Getting started with Python for .NET
Thread-Index: AQHNvO20ayuTgqDhmUqScaXJrd1tvw==
In-Reply-To: <mailman.45.1352286004.19033.pythondotnet-+ZN9ApsXKcEdnm+***@public.gmane.org>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-originating-ip: [10.0.34.57]
X-Barracuda-Connect: srvna-ex01.allenvanguard.local[10.0.33.97]
X-Barracuda-Start-Time: 1352295739
X-Barracuda-Encrypted: AES128-SHA
X-Barracuda-URL: http://mail2.allenvanguard.com:80/cgi-mod/mark.cgi
X-Virus-Scanned: by bsmtpd at allenvanguard.com
X-BeenThere: pythondotnet-+ZN9ApsXKcEdnm+***@public.gmane.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: "A list for users and developers of Python for .NET"
<pythondotnet.python.org>
List-Unsubscribe: <http://mail.python.org/mailman/options/pythondotnet>,
<mailto:pythondotnet-request-+ZN9ApsXKcEdnm+***@public.gmane.org?subject=unsubscribe>
List-Archive: <http://mail.python.org/pipermail/pythondotnet/>
List-Post: <mailto:pythondotnet-+ZN9ApsXKcEdnm+***@public.gmane.org>
List-Help: <mailto:pythondotnet-request-+ZN9ApsXKcEdnm+***@public.gmane.org?subject=help>
List-Subscribe: <http://mail.python.org/mailman/listinfo/pythondotnet>,
<mailto:pythondotnet-request-+ZN9ApsXKcEdnm+***@public.gmane.org?subject=subscribe>
Errors-To: pythondotnet-bounces+gcpd-pythondotnet=m.gmane.org-+ZN9ApsXKcEdnm+***@public.gmane.org
Sender: "PythonDotNet"
<pythondotnet-bounces+gcpd-pythondotnet=m.gmane.org-+ZN9ApsXKcEdnm+***@public.gmane.org>
Archived-At: <http://permalink.gmane.org/gmane.comp.python.dotnet/1231>

You do not need to add the extension in the AddReference call.
Just clr.AddReference("DotNet4Class")
From DotNet4Class import *

----------------------------------------------------------------------

Message: 1
Date: Tue, 6 Nov 2012 19:08:59 +0000 (UTC)
From: Anneka Boccio <adp-+wT8y+m8/***@public.gmane.org>
To: pythondotnet-+ZN9ApsXKcEdnm+***@public.gmane.org
Subject: [Python.NET] Getting started with Python for .NET
Message-ID: <loom.20121106T200549-162-eS7Uydv5nfjZ+***@public.gmane.org>
Content-Type: text/plain; charset=us-ascii

I'm completely new to Python for .Net, and I actually have very little experience with Python and no experience with C#. So please forgive me if my question seems very basic.

I'm using Python 2.7.3, and I downloaded
pythonnet-2.0-alpha2-clr2.0_131_py27_UCS2 and unzipped it into a folder named pyfornet_test, which also contains the dll I'm trying to use (called
DotNet4Class.dll)

Then I run this:
import sys
import os
import clr
sys.path.append(r"C:\pyfornet_test")
clr.AddReference("DotNet4Class.dll")

Which gives me this error:
System.IO.FileNotFoundException: Unable to find assembly 'DotNet4Class.dll'.
at Python.Runtime.CLRModule.AddReference(String name) in C:\Users\Barton\Documents\Visual Studio 2008\Projects\PyShar p\trunk\pythonnet\src\runtime\moduleobject.cs:line 375


Any advice would be much appreciated. Thank you!





------------------------------

Subject: Digest Footer

_______________________________________________
PythonDotNet mailing list
PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
http://mail.python.org/mailman/listinfo/pythondotnet


------------------------------

End of PythonDotNet Digest, Vol 103, Issue 7
********************************************

This message is intended only for the use of the named addressee. It may contain information that is copywritten, privileged, confidential and exempt from disclosure under applicable law. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this in error, please notify the sender immediately and delete it from your system. Communications using this system are monitored and recorded for lawful business purposes.
_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
http://mail.python.org/mailman/listinfo/pythondotnet

Loading...