From patstew at gmail.com Tue Jul 2 11:35:10 2013 From: patstew at gmail.com (Patrick Stewart) Date: Tue, 2 Jul 2013 10:35:10 +0100 Subject: [Python.NET] C# dynamic object support / Easy calling from C# Message-ID: Hi, Just thought I'd send a heads up to say I've made some modifications to python.net to make it much more convenient to call python code from C#, which can be found here: http://github.com/patstew/pythonnet I've inherited PyObject from DynamicObject, wired up the appropriate bits and added a few convenience functions, so now you can write C# code like this: static void Main(string[] args) { using (Py.GIL()) { dynamic np = Py.Import("numpy"); dynamic sin = np.sin; Console.WriteLine(np.cos(np.pi*2)); Console.WriteLine(sin(5)); Console.WriteLine(np.cos(5) + sin(5)); dynamic a = np.array(new List { 1, 2, 3 }; dynamic b = np.array(new List { 6, 5, 4 }, Py.kw("dtype", np.int32)); Console.WriteLine(a.dtype); Console.WriteLine(b.dtype); Console.WriteLine(a * b); Console.ReadKey(); } } which outputs: 1.0 -0.958924274663 -0.6752620892 float64 int32 [ 6. 10. 12.] as you might expect. You can call, access members and perform mathematical operations all as normal. Managed arguments are automatically converted to python types when used with a python function, and mathematical operations like multiplying numpy arrays happen entirely within python. You can specify keyword arguments using Py.kw("key1", value1, "key2", value2, ....) as an extra argument to the function. One slight annoyance is that np.pi*2 works while 2*np.pi doesn't, due to limitations of DynamicObject. This is just a first shot, and I haven't actually used it much yet, so there are almost certainly bugs, leaked references, etc lurking. I'll probably keep adding to it in the near future. Hope it's useful to someone. Cheers, Patrick -------------- next part -------------- An HTML attachment was scrubbed... URL: From patstew at gmail.com Wed Jul 3 16:32:02 2013 From: patstew at gmail.com (Patrick Stewart) Date: Wed, 3 Jul 2013 14:32:02 +0000 (UTC) Subject: [Python.NET] Calling Python functions/objects forom C# code References: <000301ce70dd$746f5620$5d4e0260$@racana.com> Message-ID: Avi Mitrani writes: > I?m new to PythonDotNet, and to integrating Python & C#, and I have to say that I?m ?breaking my teeth? > Is there an example or tutorial you can direct me to? You need to do something like: var res = PyTuple.AsTuple(fibmodule.InvokeMethod("fib2", new PyObject[1] { new PyFloat(10) })); double r = (double)res.GetItem(0).AsManagedObject(typeof(double)); This sucks, so I've made some modifications so that python can be called from C# just like normal code, without all the hassle of .GetAttr and .Invoke. Using my version of pythondotnet you can just run: double r = fibmodule.fib2(10); and it does the right thing. You can find it here: https://github.com/patstew/pythonnet Cheers, Patrick From kyle.rocha at gmail.com Fri Jul 5 04:56:51 2013 From: kyle.rocha at gmail.com (Kyle Rocha) Date: Thu, 4 Jul 2013 19:56:51 -0700 Subject: [Python.NET] Python 3 version of Python for .NET Message-ID: Has anyone tried this in a 64bit process with Python 3.3? I've been trying to get it to run but I can't seem to get past "dynamic module does not define init function CLR_init" or something to that effect. From tony at pyxll.com Fri Jul 5 16:01:27 2013 From: tony at pyxll.com (Tony Roberts) Date: Fri, 5 Jul 2013 15:01:27 +0100 Subject: [Python.NET] Python 3 version of Python for .NET In-Reply-To: References: Message-ID: Yes, I made some changes to get it working in Python 3 a while ago. The code's on github: https://github.com/tonyroberts/pythonnet. I've tested it with 3.3 x64 and it works ok for me (although I've only really used the 3.2 x64 build extensively). regards, Tony On Fri, Jul 5, 2013 at 3:56 AM, Kyle Rocha wrote: > Has anyone tried this in a 64bit process with Python 3.3? > > I've been trying to get it to run but I can't seem to get past > "dynamic module does not define init function CLR_init" or something > to that effect. > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mtigges at gmail.com Fri Jul 5 16:48:30 2013 From: mtigges at gmail.com (Mark Tigges) Date: Fri, 5 Jul 2013 07:48:30 -0700 Subject: [Python.NET] C# dynamic object support / Easy calling from C# In-Reply-To: References: Message-ID: Nice work captain! (sorry, couldn't resist.) On Tue, Jul 2, 2013 at 2:35 AM, Patrick Stewart wrote: > Hi, > Just thought I'd send a heads up to say I've made some modifications to > python.net to make it much more convenient to call python code from C#, > which can be found here: http://github.com/patstew/pythonnet > I've inherited PyObject from DynamicObject, wired up the appropriate bits > and added a few convenience functions, so now you can write C# code like > this: > > static void Main(string[] args) > { > using (Py.GIL()) { > dynamic np = Py.Import("numpy"); > dynamic sin = np.sin; > Console.WriteLine(np.cos(np.pi*2)); > Console.WriteLine(sin(5)); > Console.WriteLine(np.cos(5) + sin(5)); > dynamic a = np.array(new List { 1, 2, 3 }; > dynamic b = np.array(new List { 6, 5, 4 }, Py.kw("dtype", > np.int32)); Console.WriteLine(a.dtype); > Console.WriteLine(b.dtype); > Console.WriteLine(a * b); > Console.ReadKey(); > } > } > > which outputs: > > 1.0 > -0.958924274663 > -0.6752620892 > float64 > int32 > [ 6. 10. 12.] > > as you might expect. You can call, access members and perform mathematical > operations all as normal. Managed arguments are automatically converted to > python types when used with a python function, and mathematical operations > like multiplying numpy arrays happen entirely within python. You can > specify keyword arguments using Py.kw("key1", value1, "key2", value2, ....) > as an extra argument to the function. One slight annoyance is that np.pi*2 > works while 2*np.pi doesn't, due to limitations of DynamicObject. > This is just a first shot, and I haven't actually used it much yet, so > there are almost certainly bugs, leaked references, etc lurking. I'll > probably keep adding to it in the near future. Hope it's useful to someone. > Cheers, > Patrick > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet > -------------- next part -------------- An HTML attachment was scrubbed... URL: From btribble at ea.com Fri Jul 5 18:41:55 2013 From: btribble at ea.com (Tribble, Brett) Date: Fri, 5 Jul 2013 09:41:55 -0700 Subject: [Python.NET] C# dynamic object support / Easy calling from C# In-Reply-To: References: Message-ID: Star Trek jokes, yeah, heard those... From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea.com at python.org] On Behalf Of Mark Tigges Sent: Friday, July 05, 2013 7:49 AM To: Patrick Stewart Cc: pythondotnet at python.org Subject: Re: [Python.NET] C# dynamic object support / Easy calling from C# Nice work captain! (sorry, couldn't resist.) On Tue, Jul 2, 2013 at 2:35 AM, Patrick Stewart > wrote: Hi, Just thought I'd send a heads up to say I've made some modifications to python.net to make it much more convenient to call python code from C#, which can be found here: http://github.com/patstew/pythonnet I've inherited PyObject from DynamicObject, wired up the appropriate bits and added a few convenience functions, so now you can write C# code like this: static void Main(string[] args) { using (Py.GIL()) { dynamic np = Py.Import("numpy"); dynamic sin = np.sin; Console.WriteLine(np.cos(np.pi*2)); Console.WriteLine(sin(5)); Console.WriteLine(np.cos(5) + sin(5)); dynamic a = np.array(new List { 1, 2, 3 }; dynamic b = np.array(new List { 6, 5, 4 }, Py.kw("dtype", np.int32)); Console.WriteLine(a.dtype); Console.WriteLine(b.dtype); Console.WriteLine(a * b); Console.ReadKey(); } } which outputs: 1.0 -0.958924274663 -0.6752620892 float64 int32 [ 6. 10. 12.] as you might expect. You can call, access members and perform mathematical operations all as normal. Managed arguments are automatically converted to python types when used with a python function, and mathematical operations like multiplying numpy arrays happen entirely within python. You can specify keyword arguments using Py.kw("key1", value1, "key2", value2, ....) as an extra argument to the function. One slight annoyance is that np.pi*2 works while 2*np.pi doesn't, due to limitations of DynamicObject. This is just a first shot, and I haven't actually used it much yet, so there are almost certainly bugs, leaked references, etc lurking. I'll probably keep adding to it in the near future. Hope it's useful to someone. Cheers, Patrick _________________________________________________ Python.NET mailing list - PythonDotNet at python.org http://mail.python.org/mailman/listinfo/pythondotnet -------------- next part -------------- An HTML attachment was scrubbed... URL: From kyle.rocha at gmail.com Fri Jul 5 17:19:39 2013 From: kyle.rocha at gmail.com (Kyle Rocha) Date: Fri, 5 Jul 2013 08:19:39 -0700 Subject: [Python.NET] Python 3 version of Python for .NET In-Reply-To: References: Message-ID: Ah, cheers. On 5 Jul 2013 08:16, "Tony Roberts" wrote: > Anywhere on your pythonpath should do. If you use the setupwin.py from my > github fork you should just be able to do 'python setupwin.py install' to > put it in your site-packages (best to use virtualenv if you do that). > > Tony. > > > On Fri, Jul 5, 2013 at 4:10 PM, Kyle Rocha wrote: > >> That's odd, I'll have to just keep trying. Thanks for getting most of the >> legwork done on 3.x. >> >> There must be something else I'm missing. Where are you supposed to put >> the dll? >> >> / kyle >> On 5 Jul 2013 07:01, "Tony Roberts" wrote: >> >>> Yes, I made some changes to get it working in Python 3 a while ago. The >>> code's on github: https://github.com/tonyroberts/pythonnet. >>> >>> I've tested it with 3.3 x64 and it works ok for me (although I've only >>> really used the 3.2 x64 build extensively). >>> >>> regards, >>> Tony >>> >>> >>> On Fri, Jul 5, 2013 at 3:56 AM, Kyle Rocha wrote: >>> >>>> Has anyone tried this in a 64bit process with Python 3.3? >>>> >>>> I've been trying to get it to run but I can't seem to get past >>>> "dynamic module does not define init function CLR_init" or something >>>> to that effect. >>>> _________________________________________________ >>>> Python.NET mailing list - PythonDotNet at python.org >>>> http://mail.python.org/mailman/listinfo/pythondotnet >>>> >>> >>> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kyle.rocha at gmail.com Fri Jul 5 18:54:02 2013 From: kyle.rocha at gmail.com (Kyle Rocha) Date: Fri, 5 Jul 2013 09:54:02 -0700 Subject: [Python.NET] Python 3 version of Python for .NET In-Reply-To: References: Message-ID: Is the buildclrmodule.bat dead, according to the clr module vcproj it is, yet they both get built? On 5 July 2013 08:19, Kyle Rocha wrote: > Ah, cheers. > > On 5 Jul 2013 08:16, "Tony Roberts" wrote: >> >> Anywhere on your pythonpath should do. If you use the setupwin.py from my >> github fork you should just be able to do 'python setupwin.py install' to >> put it in your site-packages (best to use virtualenv if you do that). >> >> Tony. >> >> >> On Fri, Jul 5, 2013 at 4:10 PM, Kyle Rocha wrote: >>> >>> That's odd, I'll have to just keep trying. Thanks for getting most of the >>> legwork done on 3.x. >>> >>> There must be something else I'm missing. Where are you supposed to put >>> the dll? >>> >>> / kyle >>> >>> On 5 Jul 2013 07:01, "Tony Roberts" wrote: >>>> >>>> Yes, I made some changes to get it working in Python 3 a while ago. The >>>> code's on github: https://github.com/tonyroberts/pythonnet. >>>> >>>> I've tested it with 3.3 x64 and it works ok for me (although I've only >>>> really used the 3.2 x64 build extensively). >>>> >>>> regards, >>>> Tony >>>> >>>> >>>> On Fri, Jul 5, 2013 at 3:56 AM, Kyle Rocha wrote: >>>>> >>>>> Has anyone tried this in a 64bit process with Python 3.3? >>>>> >>>>> I've been trying to get it to run but I can't seem to get past >>>>> "dynamic module does not define init function CLR_init" or something >>>>> to that effect. >>>>> _________________________________________________ >>>>> Python.NET mailing list - PythonDotNet at python.org >>>>> http://mail.python.org/mailman/listinfo/pythondotnet >>>> >>>> >> > From kyle.rocha at gmail.com Sun Jul 7 21:14:40 2013 From: kyle.rocha at gmail.com (Kyle Rocha) Date: Sun, 7 Jul 2013 12:14:40 -0700 Subject: [Python.NET] Calling Python functions/objects forom C# code In-Reply-To: References: <000301ce70dd$746f5620$5d4e0260$@racana.com> Message-ID: Hey this is excellent, however after swapping to your branch from Tony Roberts', It seems that a string returned from .net yields a list rather than a string. / kyle On 3 July 2013 07:32, Patrick Stewart wrote: > Avi Mitrani writes: > >> I?m new to PythonDotNet, and to integrating Python & C#, and I have to say > that I?m ?breaking my teeth? > >> Is there an example or tutorial you can direct me to? > > You need to do something like: > var res = PyTuple.AsTuple(fibmodule.InvokeMethod("fib2", new PyObject[1] { new > PyFloat(10) })); > double r = (double)res.GetItem(0).AsManagedObject(typeof(double)); > > This sucks, so I've made some modifications so that python can be called from > C# just like normal code, without all the hassle of .GetAttr and .Invoke. > Using my version of pythondotnet you can just run: > > double r = fibmodule.fib2(10); > > and it does the right thing. > You can find it here: https://github.com/patstew/pythonnet > > Cheers, > Patrick > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet From avi.m at racana.com Sun Jul 14 11:46:28 2013 From: avi.m at racana.com (Avi Mitrani) Date: Sun, 14 Jul 2013 12:46:28 +0300 Subject: [Python.NET] Problem while importing lxml.html Message-ID: <000001ce8077$09e24390$1da6cab0$@racana.com> Hi, I have a module that works perfectly when I use the Python interpreter. When I try to import it from c# using PythonDotNet, it fails on the line "import lxml.html". the error message is: "Object reference not set to an instance of an object". "import lxml" works OK, but "import lxml.html" fails! - What can I do to correct this? Please help! Avi -------------- next part -------------- An HTML attachment was scrubbed... URL: From jmsachs at gmail.com Mon Jul 22 20:55:59 2013 From: jmsachs at gmail.com (Jason Sachs) Date: Mon, 22 Jul 2013 11:55:59 -0700 Subject: [Python.NET] debugging Message-ID: Hi there-- I've used Python a lot but am new to pythondotnet. I got it running on Windows 7 with no problem, by unzipping the download file, making sure PYTHONPATH and PYTHONHOME were setup properly, and running npython.exe. How do you get it to run in a debugger? (either PyDev on Eclipse, or Microsoft PTVS) Also, is there a way to install it "permanently" in an existing Python installation so that it will pickup the pythondotnet bridge when you run the regular "python.exe"? --Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From btribble at ea.com Mon Jul 22 21:32:10 2013 From: btribble at ea.com (Tribble, Brett) Date: Mon, 22 Jul 2013 12:32:10 -0700 Subject: [Python.NET] debugging In-Reply-To: References: Message-ID: I would love to hear some good answers to this. I've been able to use PTVS/Visual Studio to debug either python or .NET, but trying to cross the bridge between the two leaves you debugging pythondotnet, and not the .NET project you actually want to debug. From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea.com at python.org] On Behalf Of Jason Sachs Sent: Monday, July 22, 2013 11:56 AM To: pythondotnet at python.org Subject: [Python.NET] debugging Hi there-- I've used Python a lot but am new to pythondotnet. I got it running on Windows 7 with no problem, by unzipping the download file, making sure PYTHONPATH and PYTHONHOME were setup properly, and running npython.exe. How do you get it to run in a debugger? (either PyDev on Eclipse, or Microsoft PTVS) Also, is there a way to install it "permanently" in an existing Python installation so that it will pickup the pythondotnet bridge when you run the regular "python.exe"? --Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From btribble at ea.com Mon Jul 22 22:48:36 2013 From: btribble at ea.com (Tribble, Brett) Date: Mon, 22 Jul 2013 13:48:36 -0700 Subject: [Python.NET] debugging In-Reply-To: <39A489D6-937D-4DE4-A121-4F570774D3B9@fie.us> References: <39A489D6-937D-4DE4-A121-4F570774D3B9@fie.us> Message-ID: I'm guessing that yes, it is Reflection. I'm sure I could cobble together something that works, but I haven't wanted to spend the time to play with it that much. I'm pretty used to debugging by instrumenting code with a ton of logging and "print statements" regardless. From: Bradley Friedman [mailto:brad at fie.us] Sent: Monday, July 22, 2013 1:39 PM To: Tribble, Brett Cc: Jason Sachs; pythondotnet at python.org Subject: Re: [Python.NET] debugging I'm intrigued by this Brett. Is it that all the .NET Reflection gets in the way? I could certainly see that being a problem. Though I'd think you could get around it by setting break points at the entry points of concern? This is always a problem for these kinds of cross language bridges. Often each language consumes exceptions from the other and eliminates the "uncaught exception" as a useful debug tool. Though hard-core developers will often suggest that uncaught exceptions should never be allowed anyway. So maybe that's not really a problem. An example would be very interesting to see if nothing else. On Jul 22, 2013, at 3:32 PM, "Tribble, Brett" > wrote: but trying to cross the bridge between the two leaves you debugging pythondotnet, and not the .NET project you actually want to debug. -------------- next part -------------- An HTML attachment was scrubbed... URL: From brad at fie.us Mon Jul 22 22:43:37 2013 From: brad at fie.us (Bradley Friedman) Date: Mon, 22 Jul 2013 16:43:37 -0400 Subject: [Python.NET] debugging In-Reply-To: References: Message-ID: <329EF54B-3126-480D-8FB2-31AA51DB887D@fie.us> To make PythonNet install formally inside an existing CPython, you are looking to build/acquire it as a module and install that module in your PYTHONPATH or in your site-packages for that CPython. There are a number of ways to do this. depending on what you are downloading or building and where you are deploying. You will likely need to better define your ultimate deployment requirements/needs to figure out how you'd want to approach that issue. -brad On Jul 22, 2013, at 2:55 PM, Jason Sachs wrote: > Hi there-- > > I've used Python a lot but am new to pythondotnet. I got it running on Windows 7 with no problem, by unzipping the download file, making sure PYTHONPATH and PYTHONHOME were setup properly, and running npython.exe. > > How do you get it to run in a debugger? (either PyDev on Eclipse, or Microsoft PTVS) > > Also, is there a way to install it "permanently" in an existing Python installation so that it will pickup the pythondotnet bridge when you run the regular "python.exe"? > > --Jason > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet From btribble at ea.com Mon Jul 22 23:18:11 2013 From: btribble at ea.com (Tribble, Brett) Date: Mon, 22 Jul 2013 14:18:11 -0700 Subject: [Python.NET] debugging In-Reply-To: <4BC390C9-7053-4CEE-8993-8A3D097541B9@fie.us> References: <39A489D6-937D-4DE4-A121-4F570774D3B9@fie.us> <4BC390C9-7053-4CEE-8993-8A3D097541B9@fie.us> Message-ID: Yeah, I need to upgrade to the 2.0 beta. It's nice to see that pythondotnet has PTVS devs watching it. PTVS is one of the cooler things to come out of Microsoft! From: Bradley Friedman [mailto:brad at fie.us] Sent: Monday, July 22, 2013 2:10 PM To: Tribble, Brett Cc: Jason Sachs; pythondotnet at python.org Subject: Re: [Python.NET] debugging it looks like there's something similar to the WingIDE solution, for PTVS http://pytools.codeplex.com/wikipage?title=Remote%20Debugging%20for%20Windows%2c%20Linux%20and%20OS%20X -brad On Jul 22, 2013, at 5:05 PM, Bradley Friedman > wrote: Yea I usually do that until I give up and go through the trouble of setting up a complex debugging environment. Usually it's caused by trying to debug Python code inside of Maya. And I end up wrapping entry points in calls to the debugger. Since I'm usually using WingIDE for that, it's usually done this way: http://wingware.com/doc/debug/importing-the-debugger Likewise, when I'm stuck on a Python <--> .NET debugging problem, I usually do the same if my main entry point was a .NET one. If it's the other way around, I'm usually attaching mono-develop manually or VS manually. But the key in that case is to have breakpoints set. I've not really found a great way to launch .NET remote debugging from within a .NET runtime. But I do think the best solution will none-the-less, be a remote debugging styled solution, like it is handled in WingIDE. Or, how something like Unity3D handles mono debugging as remote debugging. I have messed around with the Debugging classes inside of .NET a little bit. And they can be useful for things like making your app pause until a debugger is attached, and such. On Jul 22, 2013, at 4:48 PM, "Tribble, Brett" > wrote: I'm guessing that yes, it is Reflection. I'm sure I could cobble together something that works, but I haven't wanted to spend the time to play with it that much. I'm pretty used to debugging by instrumenting code with a ton of logging and "print statements" regardless. -------------- next part -------------- An HTML attachment was scrubbed... URL: From smortaz at exchange.microsoft.com Mon Jul 22 22:59:04 2013 From: smortaz at exchange.microsoft.com (Shahrokh Mortazavi) Date: Mon, 22 Jul 2013 20:59:04 +0000 Subject: [Python.NET] debugging In-Reply-To: References: , Message-ID: <469a3e11b27a4b4888ce996d521e1bd8@DFM-DB3MBX15-08.exchange.corp.microsoft.com> hi folks, you should be able to do this. you'll need to step thru your Python.NET code until it actually calls into .NET, but from there it should be handled as any other cross-runtime call: http://i.imgur.com/IDPsWUu.png docs: https://pytools.codeplex.com/wikipage?title=Mixed-mode%20debugging video (for cpp tho): http://www.youtube.com/watch?v=wvJaKQ94lBY pls feel free to post any q's to ptvs forum on codeplex. thanks! ________________________________ From: PythonDotNet on behalf of Tribble, Brett Sent: Monday, July 22, 2013 12:32 PM To: Jason Sachs; pythondotnet at python.org Subject: Re: [Python.NET] debugging I would love to hear some good answers to this. I've been able to use PTVS/Visual Studio to debug either python or .NET, but trying to cross the bridge between the two leaves you debugging pythondotnet, and not the .NET project you actually want to debug. From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea.com at python.org] On Behalf Of Jason Sachs Sent: Monday, July 22, 2013 11:56 AM To: pythondotnet at python.org Subject: [Python.NET] debugging Hi there-- I've used Python a lot but am new to pythondotnet. I got it running on Windows 7 with no problem, by unzipping the download file, making sure PYTHONPATH and PYTHONHOME were setup properly, and running npython.exe. How do you get it to run in a debugger? (either PyDev on Eclipse, or Microsoft PTVS) Also, is there a way to install it "permanently" in an existing Python installation so that it will pickup the pythondotnet bridge when you run the regular "python.exe"? --Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From jmsachs at gmail.com Mon Jul 22 23:52:15 2013 From: jmsachs at gmail.com (Jason Sachs) Date: Mon, 22 Jul 2013 14:52:15 -0700 Subject: [Python.NET] Fwd: debugging In-Reply-To: References: <329EF54B-3126-480D-8FB2-31AA51DB887D@fie.us> Message-ID: >To make PythonNet install formally inside an existing CPython, you are looking to build/acquire it as a module and install that module in your PYTHONPATH or in your site-packages for that CPython. >There are a number of ways to do this. depending on what you are downloading or building and where you are deploying. So I can't just take the pythonnet binaries and put them on PYTHONPATH or in site-packages? I have to build it from source as a module? Either PYTHONPATH or site-packages will work for me; at this point I just want to make it work somehow. I tried with PyDev and can't seem to get it to recognize that System is a valid import. This is for an in-house tool that I need to make as easy as possible to install and use, I just need to write up the install procedure. It uses a data acquisition system which has .NET libraries but nothing for "pure" Python. On Mon, Jul 22, 2013 at 1:43 PM, Bradley Friedman wrote: > To make PythonNet install formally inside an existing CPython, you are > looking to build/acquire it as a module and install that module in your > PYTHONPATH or in your site-packages for that CPython. There are a number > of ways to do this. depending on what you are downloading or building and > where you are deploying. > > You will likely need to better define your ultimate deployment > requirements/needs to figure out how you'd want to approach that issue. > > -brad > > On Jul 22, 2013, at 2:55 PM, Jason Sachs wrote: > > > Hi there-- > > > > I've used Python a lot but am new to pythondotnet. I got it running on > Windows 7 with no problem, by unzipping the download file, making sure > PYTHONPATH and PYTHONHOME were setup properly, and running npython.exe. > > > > How do you get it to run in a debugger? (either PyDev on Eclipse, or > Microsoft PTVS) > > > > Also, is there a way to install it "permanently" in an existing Python > installation so that it will pickup the pythondotnet bridge when you run > the regular "python.exe"? > > > > --Jason > > _________________________________________________ > > Python.NET mailing list - PythonDotNet at python.org > > http://mail.python.org/mailman/listinfo/pythondotnet > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jmsachs at gmail.com Tue Jul 23 01:53:33 2013 From: jmsachs at gmail.com (Jason Sachs) Date: Mon, 22 Jul 2013 16:53:33 -0700 Subject: [Python.NET] debugging In-Reply-To: <7B73D198-1F43-45BC-A69C-6A54D162C5D0@fie.us> References: <329EF54B-3126-480D-8FB2-31AA51DB887D@fie.us> <7B73D198-1F43-45BC-A69C-6A54D162C5D0@fie.us> Message-ID: I'm still missing this. Here's what I tried (never mind Eclipse+pydev for the moment, I'm just trying to run a python.exe to get what I want) - I created a "pythonnet" directory under site-packages - I created a "pythonnet.pth" file that contains "pythonnet" - I added the 5 files from pythonnet into the "pythonnet" directory under site-packages and if I run python here's what I get: it shows up in sys.path but I can't import System and if I import clr it gives me an error. C:\>apython Python 2.7.5 |Anaconda 1.6.0 (64-bit)| (default, May 31 2013, 10:45:37) [MSC v.1 500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path ['', 'c:\\app\\python\\anaconda\\1.6.0\\Lib', 'c:\\app\\python\\anaconda\\1.6.0\ \python27.zip', 'c:\\app\\python\\anaconda\\1.6.0\\DLLs', 'c:\\app\\python\\anac onda\\1.6.0\\lib\\plat-win', 'c:\\app\\python\\anaconda\\1.6.0\\lib\\lib-tk', 'c :\\app\\python\\anaconda\\1.6.0', 'c:\\app\\python\\anaconda\\1.6.0\\lib\\site-p ackages', 'c:\\app\\python\\anaconda\\1.6.0\\lib\\site-packages\\PIL', 'c:\\app\ \python\\anaconda\\1.6.0\\lib\\site-packages\\pythonnet', 'c:\\app\\python\\anac onda\\1.6.0\\lib\\site-packages\\win32', 'c:\\app\\python\\anaconda\\1.6.0\\lib\ \site-packages\\win32\\lib', 'c:\\app\\python\\anaconda\\1.6.0\\lib\\site-packag es\\Pythonwin', 'c:\\app\\python\\anaconda\\1.6.0\\lib\\site-packages\\setuptool s-0.6c11-py2.7.egg-info'] >>> import System Traceback (most recent call last): File "", line 1, in ImportError: No module named System >>> import clr Traceback (most recent call last): File "", line 1, in ImportError: DLL load failed: %1 is not a valid Win32 application. C:\>dir c:\app\python\anaconda\1.6.0\lib\site-packages\pythonnet\ Volume in drive C is Local Disk Volume Serial Number is 8242-AA56 Directory of c:\app\python\anaconda\1.6.0\lib\site-packages\pythonnet 07/22/2013 04:43 PM . 07/22/2013 04:43 PM .. 12/29/2012 04:28 PM 3,584 clr.pyd 12/29/2012 04:27 PM 275,968 nPython.exe 12/29/2012 04:27 PM 13,824 nPython.pdb 12/29/2012 04:15 PM 375,296 Python.Runtime.dll 12/29/2012 04:15 PM 411,136 Python.Runtime.pdb 5 File(s) 1,079,808 bytes 2 Dir(s) 339,216,891,904 bytes free On Mon, Jul 22, 2013 at 3:05 PM, Bradley Friedman wrote: > You may be able to drop the binaries into those locations. Note I said > build/acquire. In that case you'd acquire. > > Deployment is another matter. > > When it comes to PyDev, you'll want to make sure it's using the PYTHONPATH > and site-packages locations you think it is. Further, you should probably > figure out if "import clr" works. And from there, work on importing .net > namespaces. If sometime fails, we'll need specific console output or stack > traces to be of any use here I'd think. > > -brad > > On Jul 22, 2013, at 5:50 PM, Jason Sachs wrote: > > >To make PythonNet install formally inside an existing CPython, you are > looking to build/acquire it as a module and install that module in your > PYTHONPATH or in your site-packages for that CPython. > >There are a number of ways to do this. depending on what you are > downloading or building and where you are deploying. > > So I can't just take the pythonnet binaries and put them on PYTHONPATH or > in site-packages? I have to build it from source as a module? Either > PYTHONPATH or site-packages will work for me; at this point I just want to > make it work somehow. I tried with PyDev and can't seem to get it to > recognize that System is a valid import. > > This is for an in-house tool that I need to make as easy as possible to > install and use, I just need to write up the install procedure. It uses a > data acquisition system which has .NET libraries but nothing for "pure" > Python. > > > On Mon, Jul 22, 2013 at 1:43 PM, Bradley Friedman wrote: > >> To make PythonNet install formally inside an existing CPython, you are >> looking to build/acquire it as a module and install that module in your >> PYTHONPATH or in your site-packages for that CPython. There are a number >> of ways to do this. depending on what you are downloading or building and >> where you are deploying. >> >> You will likely need to better define your ultimate deployment >> requirements/needs to figure out how you'd want to approach that issue. >> >> -brad >> >> On Jul 22, 2013, at 2:55 PM, Jason Sachs wrote: >> >> > Hi there-- >> > >> > I've used Python a lot but am new to pythondotnet. I got it running on >> Windows 7 with no problem, by unzipping the download file, making sure >> PYTHONPATH and PYTHONHOME were setup properly, and running npython.exe. >> > >> > How do you get it to run in a debugger? (either PyDev on Eclipse, or >> Microsoft PTVS) >> > >> > Also, is there a way to install it "permanently" in an existing Python >> installation so that it will pickup the pythondotnet bridge when you run >> the regular "python.exe"? >> > >> > --Jason >> > _________________________________________________ >> > Python.NET mailing list - PythonDotNet at python.org >> > http://mail.python.org/mailman/listinfo/pythondotnet >> >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jmsachs at gmail.com Tue Jul 23 01:54:58 2013 From: jmsachs at gmail.com (Jason Sachs) Date: Mon, 22 Jul 2013 16:54:58 -0700 Subject: [Python.NET] debugging In-Reply-To: References: <329EF54B-3126-480D-8FB2-31AA51DB887D@fie.us> <7B73D198-1F43-45BC-A69C-6A54D162C5D0@fie.us> Message-ID: ...yet when I run npython.exe it works fine: C:\>c:\app\python\anaconda\1.6.0\lib\site-packages\pythonnet\npython Python 2.7.5 |Anaconda 1.6.0 (64-bit)| (default, May 31 2013, 10:45:37) [MSC v.1 500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import System >>> On Mon, Jul 22, 2013 at 4:53 PM, Jason Sachs wrote: > I'm still missing this. Here's what I tried (never mind Eclipse+pydev for > the moment, I'm just trying to run a python.exe to get what I want) > > - I created a "pythonnet" directory under site-packages > - I created a "pythonnet.pth" file that contains "pythonnet" > - I added the 5 files from pythonnet into the "pythonnet" directory under > site-packages > > and if I run python here's what I get: it shows up in sys.path but I can't > import System and if I import clr it gives me an error. > > C:\>apython > Python 2.7.5 |Anaconda 1.6.0 (64-bit)| (default, May 31 2013, 10:45:37) > [MSC v.1 > 500 64 bit (AMD64)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> import sys > >>> sys.path > ['', 'c:\\app\\python\\anaconda\\1.6.0\\Lib', > 'c:\\app\\python\\anaconda\\1.6.0\ > \python27.zip', 'c:\\app\\python\\anaconda\\1.6.0\\DLLs', > 'c:\\app\\python\\anac > onda\\1.6.0\\lib\\plat-win', > 'c:\\app\\python\\anaconda\\1.6.0\\lib\\lib-tk', 'c > :\\app\\python\\anaconda\\1.6.0', > 'c:\\app\\python\\anaconda\\1.6.0\\lib\\site-p > ackages', 'c:\\app\\python\\anaconda\\1.6.0\\lib\\site-packages\\PIL', > 'c:\\app\ > \python\\anaconda\\1.6.0\\lib\\site-packages\\pythonnet', > 'c:\\app\\python\\anac > onda\\1.6.0\\lib\\site-packages\\win32', > 'c:\\app\\python\\anaconda\\1.6.0\\lib\ > \site-packages\\win32\\lib', > 'c:\\app\\python\\anaconda\\1.6.0\\lib\\site-packag > es\\Pythonwin', > 'c:\\app\\python\\anaconda\\1.6.0\\lib\\site-packages\\setuptool > s-0.6c11-py2.7.egg-info'] > >>> import System > Traceback (most recent call last): > File "", line 1, in > ImportError: No module named System > >>> import clr > Traceback (most recent call last): > File "", line 1, in > ImportError: DLL load failed: %1 is not a valid Win32 application. > > C:\>dir c:\app\python\anaconda\1.6.0\lib\site-packages\pythonnet\ > Volume in drive C is Local Disk > Volume Serial Number is 8242-AA56 > > Directory of c:\app\python\anaconda\1.6.0\lib\site-packages\pythonnet > > 07/22/2013 04:43 PM . > 07/22/2013 04:43 PM .. > 12/29/2012 04:28 PM 3,584 clr.pyd > 12/29/2012 04:27 PM 275,968 nPython.exe > 12/29/2012 04:27 PM 13,824 nPython.pdb > 12/29/2012 04:15 PM 375,296 Python.Runtime.dll > 12/29/2012 04:15 PM 411,136 Python.Runtime.pdb > 5 File(s) 1,079,808 bytes > 2 Dir(s) 339,216,891,904 bytes free > > > On Mon, Jul 22, 2013 at 3:05 PM, Bradley Friedman wrote: > >> You may be able to drop the binaries into those locations. Note I said >> build/acquire. In that case you'd acquire. >> >> Deployment is another matter. >> >> When it comes to PyDev, you'll want to make sure it's using the >> PYTHONPATH and site-packages locations you think it is. Further, you >> should probably figure out if "import clr" works. And from there, work on >> importing .net namespaces. If sometime fails, we'll need specific console >> output or stack traces to be of any use here I'd think. >> >> -brad >> >> On Jul 22, 2013, at 5:50 PM, Jason Sachs wrote: >> >> >To make PythonNet install formally inside an existing CPython, you are >> looking to build/acquire it as a module and install that module in your >> PYTHONPATH or in your site-packages for that CPython. >> >There are a number of ways to do this. depending on what you are >> downloading or building and where you are deploying. >> >> So I can't just take the pythonnet binaries and put them on PYTHONPATH or >> in site-packages? I have to build it from source as a module? Either >> PYTHONPATH or site-packages will work for me; at this point I just want to >> make it work somehow. I tried with PyDev and can't seem to get it to >> recognize that System is a valid import. >> >> This is for an in-house tool that I need to make as easy as possible to >> install and use, I just need to write up the install procedure. It uses a >> data acquisition system which has .NET libraries but nothing for "pure" >> Python. >> >> >> On Mon, Jul 22, 2013 at 1:43 PM, Bradley Friedman wrote: >> >>> To make PythonNet install formally inside an existing CPython, you are >>> looking to build/acquire it as a module and install that module in your >>> PYTHONPATH or in your site-packages for that CPython. There are a number >>> of ways to do this. depending on what you are downloading or building and >>> where you are deploying. >>> >>> You will likely need to better define your ultimate deployment >>> requirements/needs to figure out how you'd want to approach that issue. >>> >>> -brad >>> >>> On Jul 22, 2013, at 2:55 PM, Jason Sachs wrote: >>> >>> > Hi there-- >>> > >>> > I've used Python a lot but am new to pythondotnet. I got it running on >>> Windows 7 with no problem, by unzipping the download file, making sure >>> PYTHONPATH and PYTHONHOME were setup properly, and running npython.exe. >>> > >>> > How do you get it to run in a debugger? (either PyDev on Eclipse, or >>> Microsoft PTVS) >>> > >>> > Also, is there a way to install it "permanently" in an existing Python >>> installation so that it will pickup the pythondotnet bridge when you run >>> the regular "python.exe"? >>> > >>> > --Jason >>> > _________________________________________________ >>> > Python.NET mailing list - PythonDotNet at python.org >>> > http://mail.python.org/mailman/listinfo/pythondotnet >>> >>> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jmsachs at gmail.com Tue Jul 23 05:03:10 2013 From: jmsachs at gmail.com (Jason Sachs) Date: Mon, 22 Jul 2013 20:03:10 -0700 Subject: [Python.NET] debugging In-Reply-To: References: <329EF54B-3126-480D-8FB2-31AA51DB887D@fie.us> <7B73D198-1F43-45BC-A69C-6A54D162C5D0@fie.us> Message-ID: is there a prebuilt version of pythonnet for x64? I tried downloading source + opening the VS10 solution file it in Visual Studio express 2013 but it gives a bunch of migration errors. On Mon, Jul 22, 2013 at 5:48 PM, Bradley Friedman wrote: > My best guess is that the pyd file is not built correctly for your python. > > When you run npython, python.runtime.dll is already linked to the .NET > executable and is active. That's why you don't need to import clr to get > going. > > But when you run it as a module, it needs to be imported to get the clr > loaded up and get python.runtime.dll linked in. The clr.pyd is a stub to > accomplish that. And it's compiled differently per platform. > > That it doesn't recognize it as a valid executable suggests either a 32/64 > bit issue, or that you might have a .pyd that's for linux, or some other > binary incompatibility. > > On Jul 22, 2013, at 7:54 PM, Jason Sachs wrote: > > ...yet when I run npython.exe it works fine: > > C:\>c:\app\python\anaconda\1.6.0\lib\site-packages\pythonnet\npython > Python 2.7.5 |Anaconda 1.6.0 (64-bit)| (default, May 31 2013, 10:45:37) > [MSC v.1 > 500 64 bit (AMD64)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> import System > >>> > > > > On Mon, Jul 22, 2013 at 4:53 PM, Jason Sachs wrote: > >> I'm still missing this. Here's what I tried (never mind Eclipse+pydev for >> the moment, I'm just trying to run a python.exe to get what I want) >> >> - I created a "pythonnet" directory under site-packages >> - I created a "pythonnet.pth" file that contains "pythonnet" >> - I added the 5 files from pythonnet into the "pythonnet" directory under >> site-packages >> >> and if I run python here's what I get: it shows up in sys.path but I >> can't import System and if I import clr it gives me an error. >> >> C:\>apython >> Python 2.7.5 |Anaconda 1.6.0 (64-bit)| (default, May 31 2013, 10:45:37) >> [MSC v.1 >> 500 64 bit (AMD64)] on win32 >> Type "help", "copyright", "credits" or "license" for more information. >> >>> import sys >> >>> sys.path >> ['', 'c:\\app\\python\\anaconda\\1.6.0\\Lib', 'c: >> \\app\\python\\anaconda\\1.6.0\ >> \python27.zip', 'c:\\app\\python\\anaconda\\1.6.0\\DLLs', 'c: >> \\app\\python\\anac >> onda\\1.6.0\\lib\\plat-win', 'c: >> \\app\\python\\anaconda\\1.6.0\\lib\\lib-tk', 'c >> :\\app\\python\\anaconda\\1.6.0', 'c: >> \\app\\python\\anaconda\\1.6.0\\lib\\site-p >> ackages', 'c:\\app\\python\\anaconda\\1.6.0\\lib\\site-packages\\PIL', >> 'c:\\app\ >> \python\\anaconda\\1.6.0\\lib\\site-packages\\pythonnet', 'c: >> \\app\\python\\anac >> onda\\1.6.0\\lib\\site-packages\\win32', 'c: >> \\app\\python\\anaconda\\1.6.0\\lib\ >> \site-packages\\win32\\lib', 'c: >> \\app\\python\\anaconda\\1.6.0\\lib\\site-packag >> es\\Pythonwin', 'c: >> \\app\\python\\anaconda\\1.6.0\\lib\\site-packages\\setuptool >> s-0.6c11-py2.7.egg-info'] >> >>> import System >> Traceback (most recent call last): >> File "", line 1, in >> ImportError: No module named System >> >>> import clr >> Traceback (most recent call last): >> File "", line 1, in >> ImportError: DLL load failed: %1 is not a valid Win32 application. >> >> C:\>dir c:\app\python\anaconda\1.6.0\lib\site-packages\pythonnet\ >> Volume in drive C is Local Disk >> Volume Serial Number is 8242-AA56 >> >> Directory of c:\app\python\anaconda\1.6.0\lib\site-packages\pythonnet >> >> 07/22/2013 04:43 PM . >> 07/22/2013 04:43 PM .. >> 12/29/2012 04:28 PM 3,584 clr.pyd >> 12/29/2012 04:27 PM 275,968 nPython.exe >> 12/29/2012 04:27 PM 13,824 nPython.pdb >> 12/29/2012 04:15 PM 375,296 Python.Runtime.dll >> 12/29/2012 04:15 PM 411,136 Python.Runtime.pdb >> 5 File(s) 1,079,808 bytes >> 2 Dir(s) 339,216,891,904 bytes free >> >> >> On Mon, Jul 22, 2013 at 3:05 PM, Bradley Friedman wrote: >> >>> You may be able to drop the binaries into those locations. Note I said >>> build/acquire. In that case you'd acquire. >>> >>> Deployment is another matter. >>> >>> When it comes to PyDev, you'll want to make sure it's using the >>> PYTHONPATH and site-packages locations you think it is. Further, you >>> should probably figure out if "import clr" works. And from there, work on >>> importing .net namespaces. If sometime fails, we'll need specific console >>> output or stack traces to be of any use here I'd think. >>> >>> -brad >>> >>> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony at pyxll.com Tue Jul 23 16:48:36 2013 From: tony at pyxll.com (Tony Roberts) Date: Tue, 23 Jul 2013 15:48:36 +0100 Subject: [Python.NET] debugging In-Reply-To: References: <329EF54B-3126-480D-8FB2-31AA51DB887D@fie.us> <7B73D198-1F43-45BC-A69C-6A54D162C5D0@fie.us> Message-ID: There's my fork on github with x64 support: https://github.com/tonyroberts/pythonnet It might be a bit out of date now as I've not been pulling changes from the main repo recently. You can download my pre-built eggs from http://www.pyxll.com/pythonnet if you want. I've been using the x64 Python 3.2 build for a few months now with no problems. cheers, Tony On Tue, Jul 23, 2013 at 4:03 AM, Jason Sachs wrote: > is there a prebuilt version of pythonnet for x64? I tried downloading source > + opening the VS10 solution file it in Visual Studio express 2013 but it > gives a bunch of migration errors. > > > On Mon, Jul 22, 2013 at 5:48 PM, Bradley Friedman wrote: >> >> My best guess is that the pyd file is not built correctly for your python. >> >> When you run npython, python.runtime.dll is already linked to the .NET >> executable and is active. That's why you don't need to import clr to get >> going. >> >> But when you run it as a module, it needs to be imported to get the clr >> loaded up and get python.runtime.dll linked in. The clr.pyd is a stub to >> accomplish that. And it's compiled differently per platform. >> >> That it doesn't recognize it as a valid executable suggests either a 32/64 >> bit issue, or that you might have a .pyd that's for linux, or some other >> binary incompatibility. >> >> On Jul 22, 2013, at 7:54 PM, Jason Sachs wrote: >> >> ...yet when I run npython.exe it works fine: >> >> C:\>c:\app\python\anaconda\1.6.0\lib\site-packages\pythonnet\npython >> Python 2.7.5 |Anaconda 1.6.0 (64-bit)| (default, May 31 2013, 10:45:37) >> [MSC v.1 >> 500 64 bit (AMD64)] on win32 >> Type "help", "copyright", "credits" or "license" for more information. >> >>> import System >> >>> >> >> >> >> On Mon, Jul 22, 2013 at 4:53 PM, Jason Sachs wrote: >>> >>> I'm still missing this. Here's what I tried (never mind Eclipse+pydev for >>> the moment, I'm just trying to run a python.exe to get what I want) >>> >>> - I created a "pythonnet" directory under site-packages >>> - I created a "pythonnet.pth" file that contains "pythonnet" >>> - I added the 5 files from pythonnet into the "pythonnet" directory under >>> site-packages >>> >>> and if I run python here's what I get: it shows up in sys.path but I >>> can't import System and if I import clr it gives me an error. >>> >>> C:\>apython >>> Python 2.7.5 |Anaconda 1.6.0 (64-bit)| (default, May 31 2013, 10:45:37) >>> [MSC v.1 >>> 500 64 bit (AMD64)] on win32 >>> Type "help", "copyright", "credits" or "license" for more information. >>> >>> import sys >>> >>> sys.path >>> ['', 'c:\\app\\python\\anaconda\\1.6.0\\Lib', >>> 'c:\\app\\python\\anaconda\\1.6.0\ >>> \python27.zip', 'c:\\app\\python\\anaconda\\1.6.0\\DLLs', >>> 'c:\\app\\python\\anac >>> onda\\1.6.0\\lib\\plat-win', >>> 'c:\\app\\python\\anaconda\\1.6.0\\lib\\lib-tk', 'c >>> :\\app\\python\\anaconda\\1.6.0', >>> 'c:\\app\\python\\anaconda\\1.6.0\\lib\\site-p >>> ackages', 'c:\\app\\python\\anaconda\\1.6.0\\lib\\site-packages\\PIL', >>> 'c:\\app\ >>> \python\\anaconda\\1.6.0\\lib\\site-packages\\pythonnet', >>> 'c:\\app\\python\\anac >>> onda\\1.6.0\\lib\\site-packages\\win32', >>> 'c:\\app\\python\\anaconda\\1.6.0\\lib\ >>> \site-packages\\win32\\lib', >>> 'c:\\app\\python\\anaconda\\1.6.0\\lib\\site-packag >>> es\\Pythonwin', >>> 'c:\\app\\python\\anaconda\\1.6.0\\lib\\site-packages\\setuptool >>> s-0.6c11-py2.7.egg-info'] >>> >>> import System >>> Traceback (most recent call last): >>> File "", line 1, in >>> ImportError: No module named System >>> >>> import clr >>> Traceback (most recent call last): >>> File "", line 1, in >>> ImportError: DLL load failed: %1 is not a valid Win32 application. >>> >>> C:\>dir c:\app\python\anaconda\1.6.0\lib\site-packages\pythonnet\ >>> Volume in drive C is Local Disk >>> Volume Serial Number is 8242-AA56 >>> >>> Directory of c:\app\python\anaconda\1.6.0\lib\site-packages\pythonnet >>> >>> 07/22/2013 04:43 PM . >>> 07/22/2013 04:43 PM .. >>> 12/29/2012 04:28 PM 3,584 clr.pyd >>> 12/29/2012 04:27 PM 275,968 nPython.exe >>> 12/29/2012 04:27 PM 13,824 nPython.pdb >>> 12/29/2012 04:15 PM 375,296 Python.Runtime.dll >>> 12/29/2012 04:15 PM 411,136 Python.Runtime.pdb >>> 5 File(s) 1,079,808 bytes >>> 2 Dir(s) 339,216,891,904 bytes free >>> >>> >>> On Mon, Jul 22, 2013 at 3:05 PM, Bradley Friedman wrote: >>>> >>>> You may be able to drop the binaries into those locations. Note I said >>>> build/acquire. In that case you'd acquire. >>>> >>>> Deployment is another matter. >>>> >>>> When it comes to PyDev, you'll want to make sure it's using the >>>> PYTHONPATH and site-packages locations you think it is. Further, you should >>>> probably figure out if "import clr" works. And from there, work on >>>> importing .net namespaces. If sometime fails, we'll need specific console >>>> output or stack traces to be of any use here I'd think. >>>> >>>> -brad >>>> >> > > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet From krausda at gmx.de Tue Jul 23 17:39:16 2013 From: krausda at gmx.de (Daniel Krause) Date: Tue, 23 Jul 2013 17:39:16 +0200 Subject: [Python.NET] debugging In-Reply-To: References: <329EF54B-3126-480D-8FB2-31AA51DB887D@fie.us> <7B73D198-1F43-45BC-A69C-6A54D162C5D0@fie.us> Message-ID: This link might help you: http://www.lfd.uci.edu/~gohlke/pythonlibs/ 2013/7/23 Jason Sachs > is there a prebuilt version of pythonnet for x64? I tried downloading > source + opening the VS10 solution file it in Visual Studio express 2013 > but it gives a bunch of migration errors. > > > On Mon, Jul 22, 2013 at 5:48 PM, Bradley Friedman wrote: > >> My best guess is that the pyd file is not built correctly for your python. >> >> When you run npython, python.runtime.dll is already linked to the .NET >> executable and is active. That's why you don't need to import clr to get >> going. >> >> But when you run it as a module, it needs to be imported to get the clr >> loaded up and get python.runtime.dll linked in. The clr.pyd is a stub to >> accomplish that. And it's compiled differently per platform. >> >> That it doesn't recognize it as a valid executable suggests either a >> 32/64 bit issue, or that you might have a .pyd that's for linux, or some >> other binary incompatibility. >> >> On Jul 22, 2013, at 7:54 PM, Jason Sachs wrote: >> >> ...yet when I run npython.exe it works fine: >> >> C:\>c:\app\python\anaconda\1.6.0\lib\site-packages\pythonnet\npython >> Python 2.7.5 |Anaconda 1.6.0 (64-bit)| (default, May 31 2013, 10:45:37) >> [MSC v.1 >> 500 64 bit (AMD64)] on win32 >> Type "help", "copyright", "credits" or "license" for more information. >> >>> import System >> >>> >> >> >> >> On Mon, Jul 22, 2013 at 4:53 PM, Jason Sachs wrote: >> >>> I'm still missing this. Here's what I tried (never mind Eclipse+pydev >>> for the moment, I'm just trying to run a python.exe to get what I want) >>> >>> - I created a "pythonnet" directory under site-packages >>> - I created a "pythonnet.pth" file that contains "pythonnet" >>> - I added the 5 files from pythonnet into the "pythonnet" directory >>> under site-packages >>> >>> and if I run python here's what I get: it shows up in sys.path but I >>> can't import System and if I import clr it gives me an error. >>> >>> C:\>apython >>> Python 2.7.5 |Anaconda 1.6.0 (64-bit)| (default, May 31 2013, 10:45:37) >>> [MSC v.1 >>> 500 64 bit (AMD64)] on win32 >>> Type "help", "copyright", "credits" or "license" for more information. >>> >>> import sys >>> >>> sys.path >>> ['', 'c:\\app\\python\\anaconda\\1.6.0\\Lib', 'c: >>> \\app\\python\\anaconda\\1.6.0\ >>> \python27.zip', 'c:\\app\\python\\anaconda\\1.6.0\\DLLs', 'c: >>> \\app\\python\\anac >>> onda\\1.6.0\\lib\\plat-win', 'c: >>> \\app\\python\\anaconda\\1.6.0\\lib\\lib-tk', 'c >>> :\\app\\python\\anaconda\\1.6.0', 'c: >>> \\app\\python\\anaconda\\1.6.0\\lib\\site-p >>> ackages', 'c:\\app\\python\\anaconda\\1.6.0\\lib\\site-packages\\PIL', >>> 'c:\\app\ >>> \python\\anaconda\\1.6.0\\lib\\site-packages\\pythonnet', 'c: >>> \\app\\python\\anac >>> onda\\1.6.0\\lib\\site-packages\\win32', 'c: >>> \\app\\python\\anaconda\\1.6.0\\lib\ >>> \site-packages\\win32\\lib', 'c: >>> \\app\\python\\anaconda\\1.6.0\\lib\\site-packag >>> es\\Pythonwin', 'c: >>> \\app\\python\\anaconda\\1.6.0\\lib\\site-packages\\setuptool >>> s-0.6c11-py2.7.egg-info'] >>> >>> import System >>> Traceback (most recent call last): >>> File "", line 1, in >>> ImportError: No module named System >>> >>> import clr >>> Traceback (most recent call last): >>> File "", line 1, in >>> ImportError: DLL load failed: %1 is not a valid Win32 application. >>> >>> C:\>dir c:\app\python\anaconda\1.6.0\lib\site-packages\pythonnet\ >>> Volume in drive C is Local Disk >>> Volume Serial Number is 8242-AA56 >>> >>> Directory of c:\app\python\anaconda\1.6.0\lib\site-packages\pythonnet >>> >>> 07/22/2013 04:43 PM . >>> 07/22/2013 04:43 PM .. >>> 12/29/2012 04:28 PM 3,584 clr.pyd >>> 12/29/2012 04:27 PM 275,968 nPython.exe >>> 12/29/2012 04:27 PM 13,824 nPython.pdb >>> 12/29/2012 04:15 PM 375,296 Python.Runtime.dll >>> 12/29/2012 04:15 PM 411,136 Python.Runtime.pdb >>> 5 File(s) 1,079,808 bytes >>> 2 Dir(s) 339,216,891,904 bytes free >>> >>> >>> On Mon, Jul 22, 2013 at 3:05 PM, Bradley Friedman wrote: >>> >>>> You may be able to drop the binaries into those locations. Note I said >>>> build/acquire. In that case you'd acquire. >>>> >>>> Deployment is another matter. >>>> >>>> When it comes to PyDev, you'll want to make sure it's using the >>>> PYTHONPATH and site-packages locations you think it is. Further, you >>>> should probably figure out if "import clr" works. And from there, work on >>>> importing .net namespaces. If sometime fails, we'll need specific console >>>> output or stack traces to be of any use here I'd think. >>>> >>>> -brad >>>> >>>> >> > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jmsachs at gmail.com Tue Jul 23 20:30:58 2013 From: jmsachs at gmail.com (Jason Sachs) Date: Tue, 23 Jul 2013 11:30:58 -0700 Subject: [Python.NET] debugging In-Reply-To: References: <329EF54B-3126-480D-8FB2-31AA51DB887D@fie.us> <7B73D198-1F43-45BC-A69C-6A54D162C5D0@fie.us> Message-ID: thanks both of you! On Tue, Jul 23, 2013 at 8:39 AM, Daniel Krause wrote: > This link might help you: > http://www.lfd.uci.edu/~gohlke/pythonlibs/ > > > 2013/7/23 Jason Sachs > >> is there a prebuilt version of pythonnet for x64? I tried downloading >> source + opening the VS10 solution file it in Visual Studio express 2013 >> but it gives a bunch of migration errors. >> >> >> On Mon, Jul 22, 2013 at 5:48 PM, Bradley Friedman wrote: >> >>> My best guess is that the pyd file is not built correctly for your >>> python. >>> >>> When you run npython, python.runtime.dll is already linked to the .NET >>> executable and is active. That's why you don't need to import clr to get >>> going. >>> >>> But when you run it as a module, it needs to be imported to get the clr >>> loaded up and get python.runtime.dll linked in. The clr.pyd is a stub to >>> accomplish that. And it's compiled differently per platform. >>> >>> That it doesn't recognize it as a valid executable suggests either a >>> 32/64 bit issue, or that you might have a .pyd that's for linux, or some >>> other binary incompatibility. >>> >>> On Jul 22, 2013, at 7:54 PM, Jason Sachs wrote: >>> >>> ...yet when I run npython.exe it works fine: >>> >>> C:\>c:\app\python\anaconda\1.6.0\lib\site-packages\pythonnet\npython >>> Python 2.7.5 |Anaconda 1.6.0 (64-bit)| (default, May 31 2013, 10:45:37) >>> [MSC v.1 >>> 500 64 bit (AMD64)] on win32 >>> Type "help", "copyright", "credits" or "license" for more information. >>> >>> import System >>> >>> >>> >>> >>> >>> On Mon, Jul 22, 2013 at 4:53 PM, Jason Sachs wrote: >>> >>>> I'm still missing this. Here's what I tried (never mind Eclipse+pydev >>>> for the moment, I'm just trying to run a python.exe to get what I want) >>>> >>>> - I created a "pythonnet" directory under site-packages >>>> - I created a "pythonnet.pth" file that contains "pythonnet" >>>> - I added the 5 files from pythonnet into the "pythonnet" directory >>>> under site-packages >>>> >>>> and if I run python here's what I get: it shows up in sys.path but I >>>> can't import System and if I import clr it gives me an error. >>>> >>>> C:\>apython >>>> Python 2.7.5 |Anaconda 1.6.0 (64-bit)| (default, May 31 2013, 10:45:37) >>>> [MSC v.1 >>>> 500 64 bit (AMD64)] on win32 >>>> Type "help", "copyright", "credits" or "license" for more information. >>>> >>> import sys >>>> >>> sys.path >>>> ['', 'c:\\app\\python\\anaconda\\1.6.0\\Lib', 'c: >>>> \\app\\python\\anaconda\\1.6.0\ >>>> \python27.zip', 'c:\\app\\python\\anaconda\\1.6.0\\DLLs', 'c: >>>> \\app\\python\\anac >>>> onda\\1.6.0\\lib\\plat-win', 'c: >>>> \\app\\python\\anaconda\\1.6.0\\lib\\lib-tk', 'c >>>> :\\app\\python\\anaconda\\1.6.0', 'c: >>>> \\app\\python\\anaconda\\1.6.0\\lib\\site-p >>>> ackages', 'c:\\app\\python\\anaconda\\1.6.0\\lib\\site-packages\\PIL', >>>> 'c:\\app\ >>>> \python\\anaconda\\1.6.0\\lib\\site-packages\\pythonnet', 'c: >>>> \\app\\python\\anac >>>> onda\\1.6.0\\lib\\site-packages\\win32', 'c: >>>> \\app\\python\\anaconda\\1.6.0\\lib\ >>>> \site-packages\\win32\\lib', 'c: >>>> \\app\\python\\anaconda\\1.6.0\\lib\\site-packag >>>> es\\Pythonwin', 'c: >>>> \\app\\python\\anaconda\\1.6.0\\lib\\site-packages\\setuptool >>>> s-0.6c11-py2.7.egg-info'] >>>> >>> import System >>>> Traceback (most recent call last): >>>> File "", line 1, in >>>> ImportError: No module named System >>>> >>> import clr >>>> Traceback (most recent call last): >>>> File "", line 1, in >>>> ImportError: DLL load failed: %1 is not a valid Win32 application. >>>> >>>> C:\>dir c:\app\python\anaconda\1.6.0\lib\site-packages\pythonnet\ >>>> Volume in drive C is Local Disk >>>> Volume Serial Number is 8242-AA56 >>>> >>>> Directory of c:\app\python\anaconda\1.6.0\lib\site-packages\pythonnet >>>> >>>> 07/22/2013 04:43 PM . >>>> 07/22/2013 04:43 PM .. >>>> 12/29/2012 04:28 PM 3,584 clr.pyd >>>> 12/29/2012 04:27 PM 275,968 nPython.exe >>>> 12/29/2012 04:27 PM 13,824 nPython.pdb >>>> 12/29/2012 04:15 PM 375,296 Python.Runtime.dll >>>> 12/29/2012 04:15 PM 411,136 Python.Runtime.pdb >>>> 5 File(s) 1,079,808 bytes >>>> 2 Dir(s) 339,216,891,904 bytes free >>>> >>>> >>>> On Mon, Jul 22, 2013 at 3:05 PM, Bradley Friedman wrote: >>>> >>>>> You may be able to drop the binaries into those locations. Note I >>>>> said build/acquire. In that case you'd acquire. >>>>> >>>>> Deployment is another matter. >>>>> >>>>> When it comes to PyDev, you'll want to make sure it's using the >>>>> PYTHONPATH and site-packages locations you think it is. Further, you >>>>> should probably figure out if "import clr" works. And from there, work on >>>>> importing .net namespaces. If sometime fails, we'll need specific console >>>>> output or stack traces to be of any use here I'd think. >>>>> >>>>> -brad >>>>> >>>>> >>> >> >> _________________________________________________ >> Python.NET mailing list - PythonDotNet at python.org >> http://mail.python.org/mailman/listinfo/pythondotnet >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jmsachs at gmail.com Tue Jul 23 22:45:52 2013 From: jmsachs at gmail.com (Jason Sachs) Date: Tue, 23 Jul 2013 13:45:52 -0700 Subject: [Python.NET] C# path for 3rd-party libraries? Message-ID: I got the pythonnet libraries installed and working with my Python installation, and I can do import clr import System without errors, but when I go to import a 3rd-party .NET library I have installed, it can't find it: >>> import clr >>> import System >>> import OpenLayers.Base Traceback (most recent call last): File "", line 1, in ImportError: No module named OpenLayers.Base >>> How do I tell pythonnet where .NET libraries are? I have essentially no background with .NET, I'm familiar with Java so there are a lot of parallels but I don't understand how to make these libraries visible to Python. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jmsachs at gmail.com Tue Jul 23 23:05:36 2013 From: jmsachs at gmail.com (Jason Sachs) Date: Tue, 23 Jul 2013 14:05:36 -0700 Subject: [Python.NET] C# path for 3rd-party libraries? In-Reply-To: References: Message-ID: Never mind, I figured it out, you just have to make sure the .dll files are in the PYTHONPATH. On Tue, Jul 23, 2013 at 1:45 PM, Jason Sachs wrote: > I got the pythonnet libraries installed and working with my Python > installation, and I can do > > import clr > import System > > without errors, but when I go to import a 3rd-party .NET library I have > installed, it can't find it: > > >>> import clr > >>> import System > >>> import OpenLayers.Base > Traceback (most recent call last): > File "", line 1, in > ImportError: No module named OpenLayers.Base > >>> > > How do I tell pythonnet where .NET libraries are? I have essentially no > background with .NET, I'm familiar with Java so there are a lot of > parallels but I don't understand how to make these libraries visible to > Python. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From btribble at ea.com Wed Jul 24 00:07:09 2013 From: btribble at ea.com (Tribble, Brett) Date: Tue, 23 Jul 2013 15:07:09 -0700 Subject: [Python.NET] C# path for 3rd-party libraries? In-Reply-To: References: Message-ID: I think you can register them in the GAC as well, but this is a pain in the butt to maintain. http://en.wikipedia.org/wiki/Global_Assembly_Cache From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea.com at python.org] On Behalf Of Jason Sachs Sent: Tuesday, July 23, 2013 2:06 PM To: pythondotnet at python.org Subject: Re: [Python.NET] C# path for 3rd-party libraries? Never mind, I figured it out, you just have to make sure the .dll files are in the PYTHONPATH. On Tue, Jul 23, 2013 at 1:45 PM, Jason Sachs > wrote: I got the pythonnet libraries installed and working with my Python installation, and I can do import clr import System without errors, but when I go to import a 3rd-party .NET library I have installed, it can't find it: >>> import clr >>> import System >>> import OpenLayers.Base Traceback (most recent call last): File "", line 1, in ImportError: No module named OpenLayers.Base >>> How do I tell pythonnet where .NET libraries are? I have essentially no background with .NET, I'm familiar with Java so there are a lot of parallels but I don't understand how to make these libraries visible to Python. -------------- next part -------------- An HTML attachment was scrubbed... URL: