[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 _ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet
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@python.org] On Behalf Of Jason Sachs Sent: Monday, July 22, 2013 11:56 AM To: pythondotnet@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 _ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet
Re: [Python.NET] debugging
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:b...@fie.us] Sent: Monday, July 22, 2013 1:39 PM To: Tribble, Brett Cc: Jason Sachs; pythondotnet@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" mailto:btrib...@ea.com>> wrote: but trying to cross the bridge between the two leaves you debugging pythondotnet, and not the .NET project you actually want to debug. _ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet
Re: [Python.NET] debugging
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:b...@fie.us] Sent: Monday, July 22, 2013 2:10 PM To: Tribble, Brett Cc: Jason Sachs; pythondotnet@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 mailto:b...@fie.us>> 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" mailto:btrib...@ea.com>> 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. _ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet
Re: [Python.NET] debugging
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@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@python.org] On Behalf Of Jason Sachs Sent: Monday, July 22, 2013 11:56 AM To: pythondotnet@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 _ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet
[Python.NET] Fwd: debugging
>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@python.org > > http://mail.python.org/mailman/listinfo/pythondotnet > > _ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet
Re: [Python.NET] debugging
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 PM13,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
Re: [Python.NET] debugging
...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 PM13,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