[Pythonmac-SIG] Opening an app from another app under different OSX versions -- SOLVED

Bob Ippolito bob at redivi.com
Thu Jan 25 20:12:21 CET 2007


On 1/25/07, David Woods <dwoods at wcer.wisc.edu> wrote:
> > On 1/24/07, David Woods <dwoods at wcer.wisc.edu> wrote:
> > > > > Adding the path didn't help.  Calling "open -a
> > TransanaHelp.app"
> > > > > from the command line finds the app, and adding the full path
> > > > > makes
> > > > is start
> > > > > a bit
> > > > > faster.  But when the same call is made from within my
> > > > bundled Python
> > > > > program (regardless of whether the path is included), I see the
> > > > > following in the console:
> > > > >
> > > > > 'import site' failed; use -v for traceback
> > > > > Traceback (most recent call last):
> > > > >   File
> > "/Applications/Transana_2/TransanaHelp.app/Contents/MacOS/
> > > > > TransanaHelp",
> > > > > line 3, in ?
> > > > >     import sys, os
> > > > > ImportError: No module named os
> > > > >
> > > > > So it seems, if I'm interpreting this right, like Python's not
> > > > > able to find its own modules under this particular
> > scenario.  Line
> > > > > 3 of TransanaHelp.py,
> > > > > by the way, is not the import statement shown here.  That
> > > > line 3 is
> > > > > of some
> > > > > internal Python routine that's not part of my code.
> > > >
> > > > I had a problem like this when first moving from distutils-based
> > > > setup files to setuptools-based setup files.  Getting the latest
> > > > version of py2app may help.
> > > >
> > > > --Dethe
> > >
> > > Upgrading to py2app 0.3.5 had absolutely no effect.
> > >
> >
> > It's *probably* because py2app sets a lot of environment
> > variables that can effect child Python interpreters... Try
> > clearing out any PY* environment variables sometime early in
> > your script.
> >
> > -bob
>
>
> Bob,
>
> That was indeed the source of the problem.  I now delete the PYTHONHOME,
> PYTHONPATH, and PYTHONEXECUTABLE environment variables before the
> os.system() call and the Help application shows up as it should.
>
> Am I likely to see side-effects from deleting these environment variables?
> Should I restore them to their original values after the Help call has been
> made?

No, there will not be side-effects. Those variables are used by
py2app's bootstrap executable to communicate with the Python
interpreter on startup and that's it.

> Thanks a ton for your help.  I *NEVER* would've figure this one out.

It's certainly not obvious. I only knew what it was because I wrote py2app ;)

-bob


More information about the Pythonmac-SIG mailing list