[Pythonmac-SIG] Python embedding in LabVIEW on Mac? (oops, found part of the problem)

Marcus H. Mendenhall marcus.h.mendenhall@vanderbilt.edu
Thu, 20 Jun 2002 16:49:08 -0500


>On donderdag, juni 20, 2002, at 06:58 , Marcus H. Mendenhall wrote:
>>OK, in response to my own post (sorry), I found an oops involving 
>>calling Py_Initialize instead of PyMac_Initialize .  Now, LabVIEW 
>>gets much farther into the embedding startup, but still doesn't 
>>quite work.  The remaining, important  question is whether any has 
>>had this work under newer version of LabVIEW, since the 5.0.1 
>>release is quite old.
>
>Calling PyMac_Initialize() in stead of Py_Initialize() is definitely 
>needed when embedding MacPython. But even then there are probably 
>pitfalls. Some I can think of:
>- the two event loops (MacPython's and LabVIEW's) may get in each 
>others way. Also, if you have windows open in both you may get a 
>continuous stream of Update Events for a window which your event 
>loop knows nothing about.
>- Python may have problems with missing some of the resources it 
>needs (to find the initial sys.path and other preferences and such). 
>Check :Mac:Demo:embed.html for some of the details (but it is by no 
>means complete).
>- It may help to set Py_VerboseFlag to 1 (or 2 for even more output) 
>before calling PyMac_Initialize. This'll give all sorts of debug 
>output for importing modules and such. But: if your problem is 
>eventloop/window/IO-system related this'll probably not work.

Thanks, Jack.  I made some progress, but I will not spend a lot of 
time before I get my LabVIEW update.  Using PyMac_Initialize results 
in the embedded python session working (I can run a dumb script which 
opens a file, writes 'hello world' to it, and closes it).  However, 
even if the interpreter opened no windows (that I can see), LabVIEW 
5.0 pops up an internal error from its window handler and exits as 
soon as control returns to LabVIEW from Python.

Even if the interpreter doesn't make any windows appear, does it 
silently mess with anything in the windowing setup?  Leave the 
current grafPort pointing so something odd?  etc.?

Marcus