Discussion:
[Python.NET] debugging
Jason Sachs
2013-07-22 18:55:59 UTC
Permalink
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
Tribble, Brett
2013-07-22 19:32:10 UTC
Permalink
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-+ZN9ApsXKcFQFI55V6+***@public.gmane.orgg] On Behalf Of Jason Sachs
Sent: Monday, July 22, 2013 11:56 AM
To: pythondotnet-+ZN9ApsXKcEdnm+***@public.gmane.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
Tribble, Brett
2013-07-22 20:48:36 UTC
Permalink
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-DLbl0k+***@public.gmane.org]
Sent: Monday, July 22, 2013 1:39 PM
To: Tribble, Brett
Cc: Jason Sachs; pythondotnet-+ZN9ApsXKcEdnm+***@public.gmane.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" <btribble-***@public.gmane.org<mailto:btribble-***@public.gmane.org>> wrote:


but trying to cross the bridge between the two leaves you debugging pythondotnet, and not the .NET project you actually want to debug.
Tribble, Brett
2013-07-22 21:18:11 UTC
Permalink
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-DLbl0k+***@public.gmane.org]
Sent: Monday, July 22, 2013 2:10 PM
To: Tribble, Brett
Cc: Jason Sachs; pythondotnet-+ZN9ApsXKcEdnm+***@public.gmane.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 <brad-DLbl0k+***@public.gmane.org<mailto:***@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" <btribble-***@public.gmane.org<mailto:btribble-***@public.gmane.org>> 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.
Shahrokh Mortazavi
2013-07-22 20:59:04 UTC
Permalink
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 <pythondotnet-bounces+smortaz=microsoft.com-+ZN9ApsXKcEdnm+***@public.gmane.org> on behalf of Tribble, Brett <btribble-***@public.gmane.org>
Sent: Monday, July 22, 2013 12:32 PM
To: Jason Sachs; pythondotnet-+ZN9ApsXKcEdnm+***@public.gmane.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-+ZN9ApsXKcFQFI55V6+***@public.gmane.orgg] On Behalf Of Jason Sachs
Sent: Monday, July 22, 2013 11:56 AM
To: pythondotnet-+ZN9ApsXKcEdnm+***@public.gmane.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
Bradley Friedman
2013-07-22 20:43:37 UTC
Permalink
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 <jmsachs-***@public.gmane.org> 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-+ZN9ApsXKcEdnm+***@public.gmane.org
> http://mail.python.org/mailman/listinfo/pythondotnet

_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
http://mail.python.org/mailman/listinfo/pythondotnet
Jason Sachs
2013-07-22 21:52:15 UTC
Permalink
>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 <brad-DLbl0k+***@public.gmane.org> 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 <jmsachs-***@public.gmane.org> 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-+ZN9ApsXKcEdnm+***@public.gmane.org
> > http://mail.python.org/mailman/listinfo/pythondotnet
>
>
Jason Sachs
2013-07-22 23:53:33 UTC
Permalink
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 "<stdin>", line 1, in <module>
ImportError: No module named System
>>> import clr
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
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 <DIR> .
07/22/2013 04:43 PM <DIR> ..
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 <brad-DLbl0k+***@public.gmane.org> 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 <jmsachs-***@public.gmane.org> 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 <brad-DLbl0k+***@public.gmane.org> 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 <jmsachs-***@public.gmane.org> 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-+ZN9ApsXKcEdnm+***@public.gmane.org
>> > http://mail.python.org/mailman/listinfo/pythondotnet
>>
>>
>
>
Jason Sachs
2013-07-22 23:54:58 UTC
Permalink
...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 <jmsachs-***@public.gmane.org> 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 "<stdin>", line 1, in <module>
> ImportError: No module named System
> >>> import clr
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> 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 <DIR> .
> 07/22/2013 04:43 PM <DIR> ..
> 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 <brad-DLbl0k+***@public.gmane.org> 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 <jmsachs-***@public.gmane.org> 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 <brad-DLbl0k+***@public.gmane.org> 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 <jmsachs-***@public.gmane.org> 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-+ZN9ApsXKcEdnm+***@public.gmane.org
>>> > http://mail.python.org/mailman/listinfo/pythondotnet
>>>
>>>
>>
>>
>
Jason Sachs
2013-07-23 03:03:10 UTC
Permalink
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 <brad-DLbl0k+***@public.gmane.org> 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 <jmsachs-***@public.gmane.org> 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 <jmsachs-***@public.gmane.org> 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 "<stdin>", line 1, in <module>
>> ImportError: No module named System
>> >>> import clr
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> 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 <DIR> .
>> 07/22/2013 04:43 PM <DIR> ..
>> 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 <brad-DLbl0k+***@public.gmane.org> 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
>>>
>>>
>
Tony Roberts
2013-07-23 14:48:36 UTC
Permalink
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 <jmsachs-***@public.gmane.org> 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 <brad-DLbl0k+***@public.gmane.org> 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 <jmsachs-***@public.gmane.org> 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 <jmsachs-***@public.gmane.org> 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 "<stdin>", line 1, in <module>
>>> ImportError: No module named System
>>> >>> import clr
>>> Traceback (most recent call last):
>>> File "<stdin>", line 1, in <module>
>>> 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 <DIR> .
>>> 07/22/2013 04:43 PM <DIR> ..
>>> 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 <brad-DLbl0k+***@public.gmane.org> 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-+ZN9ApsXKcEdnm+***@public.gmane.org
> http://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
http://mail.python.org/mailman/listinfo/pythondotnet
Daniel Krause
2013-07-23 15:39:16 UTC
Permalink
This link might help you:
http://www.lfd.uci.edu/~gohlke/pythonlibs/


2013/7/23 Jason Sachs <jmsachs-***@public.gmane.org>

> 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 <brad-DLbl0k+***@public.gmane.org> 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 <jmsachs-***@public.gmane.org> 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 <jmsachs-***@public.gmane.org> 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 "<stdin>", line 1, in <module>
>>> ImportError: No module named System
>>> >>> import clr
>>> Traceback (most recent call last):
>>> File "<stdin>", line 1, in <module>
>>> 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 <DIR> .
>>> 07/22/2013 04:43 PM <DIR> ..
>>> 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 <brad-DLbl0k+***@public.gmane.org> 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-+ZN9ApsXKcEdnm+***@public.gmane.org
> http://mail.python.org/mailman/listinfo/pythondotnet
>
Jason Sachs
2013-07-23 18:30:58 UTC
Permalink
thanks both of you!


On Tue, Jul 23, 2013 at 8:39 AM, Daniel Krause <krausda-***@public.gmane.org> wrote:

> This link might help you:
> http://www.lfd.uci.edu/~gohlke/pythonlibs/
>
>
> 2013/7/23 Jason Sachs <jmsachs-***@public.gmane.org>
>
>> 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 <brad-DLbl0k+***@public.gmane.org> 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 <jmsachs-***@public.gmane.org> 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 <jmsachs-***@public.gmane.org> 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 "<stdin>", line 1, in <module>
>>>> ImportError: No module named System
>>>> >>> import clr
>>>> Traceback (most recent call last):
>>>> File "<stdin>", line 1, in <module>
>>>> 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 <DIR> .
>>>> 07/22/2013 04:43 PM <DIR> ..
>>>> 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 <brad-DLbl0k+***@public.gmane.org> 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-+ZN9ApsXKcEdnm+***@public.gmane.org
>> http://mail.python.org/mailman/listinfo/pythondotnet
>>
>
>
Loading...