[mod_python] Mac OS X Leopard upset my mod_python test bed.

Graham Dumpleton graham.dumpleton at gmail.com
Sun Nov 25 23:25:02 EST 2007


Okay, I think I understand now. Although you have new 'python'
installed in /usr/local/bin, it hasn't installed library stuff in
/usr/local/lib, but has used
/Library/Frameworks/Python.framework/Versions/2.5/lib instead. Because
of that it will probably work, although I'd be cautious about same
major/minor version being installed under /Library.

The workarounds I described are only needed if the Python you built
was for example putting library stuff under /usr/local and thus not in
normal framework search locations.

Whatever works I guess. :-)

On 26/11/2007, Simon Kesenci <god at skri.org> wrote:
> It shows the same result as for sys.path from the interpreter I
> compiled, minus the first item (''; no newline after <pre> in the
> source).
>
> /Library/Frameworks/Python.framework/Versions/2.5/lib/python25.zip /
> Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5 /
> Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-
> darwin /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> plat-mac /Library/Frameworks/Python.framework/Versions/2.5/lib/
> python2.5/plat-mac/lib-scriptpackages /Library/Frameworks/
> Python.framework/Versions/2.5/lib/python2.5/lib-tk /Library/Frameworks/
> Python.framework/Versions/2.5/lib/python2.5/lib-dynload /Library/
> Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages
>
>
> --S.
>
> On Nov 25, 2007, at 19:50, Graham Dumpleton wrote:
>
> > If you run a mod_python test handler and display back sys.path to your
> > browser, what does it show?
> >
> > Graham
> >
> > On 26/11/2007, Simon Kesenci <god at skri.org> wrote:
> >> Not sure how the Sharing Preferences starts apache but I suspect it
> >> uses something similar to sudo.  At any rate I tried starting it the
> >> way you described and mod_python still worked as expected.
> >>
> >> I then removed /usr/local/bin from my personal account's path and
> >> logged back in, confirmed that the path lacked /usr/local/bin, used
> >> sudo -H to start apache again and mod_python still worked.
> >>
> >> I then renamed /usr/local/bin to /usr/local/bin2, restarted apache
> >> and
> >> mod_python still worked.
> >>
> >> It seems mod_python only needs to find the executable at the time you
> >> compile mod_python.
> >>
> >> Though I have my setup working, the question of where mod_python got
> >> the path in the error log in my original message remains.  Neither
> >> interpreter on my computer yields that result via sys.path (although
> >> some of the items in that list correspond, via symlinks, to locations
> >> on the path from the interpreter that came with Leopard).
> >>
> >> --S.
> >>
> >> On Nov 25, 2007, at 18:21, Graham Dumpleton wrote:
> >>
> >>> On 26/11/2007, Simon Kesenci <god at skri.org> wrote:
> >>>> I haven't found a discussion of this problem in the archives.
> >>>>
> >>>> Strange stuff.  It started working properly after I removed the /
> >>>> usr/
> >>>> sbin/httpd symlink and copied the compiled version there.  It works
> >>>> without setting PYTHONHOME and without /usr/local/bin in root's
> >>>> path.
> >>>
> >>> More than likely you used 'sudo' to restart Apache and it therefore
> >>> picked up your personal PATH which had /usr/local/bin first. Do a:
> >>>
> >>> sudo -H apachcetl stop
> >>> sudo -H apachectl start
> >>>
> >>> and see if you are so lucky. The -H option prevents your personal
> >>> user
> >>> environment transferring over to Apache startup environment.
> >>>
> >>> Graham
> >>>
> >>>> To answer your question, using the OS-provided installation
> >>>> (whatever
> >>>> the OS) leaves your software to the mercies of the OS's update
> >>>> schedule.
> >>>>
> >>>> --S.
> >>>>
> >>>> On Nov 25, 2007, at 14:17, Graham Dumpleton wrote:
> >>>>
> >>>>> In 'envvars' file in the same directory as the real httpd you want
> >>>>> to run, add:
> >>>>>
> >>>>> PYTHONHOME=/usr/local
> >>>>> export PYTHONHOME
> >>>>>
> >>>>> Alternatively, you must ensure that the PATH of the user that
> >>>>> Apache
> >>>>> is started as has /usr/local/bin in its path before /usr/bin, else
> >>>>> it
> >>>>> will find the wrong 'python' executable and thus end up looking in
> >>>>> the
> >>>>> wrong location for the corresponding lib directory.
> >>>>>
> >>>>> Search the mod_python mailing lists for past discussions on this
> >>>>> issue.
> >>>>>
> >>>>> BTW, why do you want to install your own version of Python 2.5,
> >>>>> what
> >>>>> is wrong with the Python 2.5 that the operating system ships?
> >>>>>
> >>>>> Graham
> >>>>>
> >>>>> On 26/11/2007, Simon Kesenci <god at skri.org> wrote:
> >>>>>> I recently upgraded my PowerBook (PPC) to Leopard.  Piece by
> >>>>>> piece I
> >>>>>> started reassembling my web server test bed (httpd 2.2.6, Python
> >>>>>> 2.5.1, mod_python 3.3.1), which worked perfectly on Tiger.  I
> >>>>>> built
> >>>>>> everything from their sources.
> >>>>>>
> >>>>>> This time around I got everything to work except for mod_python.
> >>>>>> My
> >>>>>> procedure had the following non-standard edits:
> >>>>>>
> >>>>>> httpd 2.2.6:
> >>>>>>   Changed APR_HAS_SENDFILE to 0 in srclib/apr/include/apr.h
> >>>>>>   After installation I backed up /usr/sbin/httpd and entered
> >>>>>>     ln -s /usr/local/apache2/bin/httpd /usr/sbin/httpd.
> >>>>>>   (This allows you to activate the compiled httpd from the
> >>>>>> Sharing
> >>>>>> Preferences, which will also have the built-in firewall open and
> >>>>>> close
> >>>>>> port 80 in sync with the server.)
> >>>>>>
> >>>>>> Python 2.5.1:
> >>>>>>   After ./configure --enable-framework I added -DSETPGRP_HAVE_ARG
> >>>>>> to the top-level Makefile (make exits with an error otherwise due
> >>>>>> to a
> >>>>>> lack of arguments to setpgrp()).
> >>>>>>
> >>>>>> Both of the above work as expected, but when I threw mod_python
> >>>>>> into
> >>>>>> the mix I kept getting the following error:
> >>>>>>
> >>>>>> [Sun Nov 25 09:43:22 2007] [error] make_obcallback: could not
> >>>>>> import
> >>>>>> mod_python.apache.\n
> >>>>>> ImportError: No module named mod_python.apache
> >>>>>> [Sun Nov 25 09:43:22 2007] [error] make_obcallback: Python path
> >>>>>> being
> >>>>>> used "['/usr/lib/python25.zip', '/usr/lib/python2.5', '/usr/lib/
> >>>>>> python2.5/plat-darwin', '/usr/lib/python2.5/plat-mac', '/usr/lib/
> >>>>>> python2.5/plat-mac/lib-scriptpackages', '/usr/lib/python2.5/lib-
> >>>>>> tk', '/
> >>>>>> usr/lib/python2.5/lib-dynload', '/Library/Python/2.5/site-
> >>>>>> packages']".
> >>>>>> [Sun Nov 25 09:43:22 2007] [error] get_interpreter: no
> >>>>>> interpreter
> >>>>>> callback found.
> >>>>>> [Sun Nov 25 09:43:22 2007] [error] [client 10.0.1.2]
> >>>>>> python_handler:
> >>>>>> Can't get/create interpreter., referer: http://10.0.1.2/~simon/
> >>>>>> test/
> >>>>>>
> >>>>>> I used a number of scripts to test the installation, including
> >>>>>> mptest.py from the mod_python doc.  The last script I used to
> >>>>>> test
> >>>>>> did
> >>>>>> not import mod_python.apache explicitly:
> >>>>>>
> >>>>>> from mod_python import util
> >>>>>>
> >>>>>> def index(req):
> >>>>>> util.redirect(req, 'www.example.com')
> >>>>>>
> >>>>>> While installing mod_python the output made clear that it took up
> >>>>>> the
> >>>>>> interpreter in /usr/local/bin rather than the one provided by
> >>>>>> Apple
> >>>>>> in /usr/bin and installed under /Library/Frameworks/
> >>>>>> Python.framework/
> >>>>>> Versions/2.5/lib/python2.5/site-packages/ rather than /Library/
> >>>>>> Python/
> >>>>>> 2.5/site-packages.
> >>>>>>
> >>>>>> I don't know from where it pulled that path.  The interpreter I
> >>>>>> compiled uses the path:
> >>>>>>
> >>>>>> ['', '/Library/Frameworks/Python.framework/Versions/2.5/lib/
> >>>>>> python25.zip', '/Library/Frameworks/Python.framework/Versions/
> >>>>>> 2.5/
> >>>>>> lib/
> >>>>>> python2.5', '/Library/Frameworks/Python.framework/Versions/2.5/
> >>>>>> lib/
> >>>>>> python2.5/plat-darwin', '/Library/Frameworks/Python.framework/
> >>>>>> Versions/
> >>>>>> 2.5/lib/python2.5/plat-mac', '/Library/Frameworks/
> >>>>>> Python.framework/
> >>>>>> Versions/2.5/lib/python2.5/plat-mac/lib-scriptpackages', '/
> >>>>>> Library/
> >>>>>> Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk',
> >>>>>> '/
> >>>>>> Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> >>>>>> lib-
> >>>>>> dynload', '/Library/Frameworks/Python.framework/Versions/2.5/lib/
> >>>>>> python2.5/site-packages']
> >>>>>>
> >>>>>> The interpreter provided by Apple uses:
> >>>>>>
> >>>>>> ['', '/System/Library/Frameworks/Python.framework/Versions/2.5/
> >>>>>> lib/
> >>>>>> python25.zip', '/System/Library/Frameworks/Python.framework/
> >>>>>> Versions/
> >>>>>> 2.5/lib/python2.5', '/System/Library/Frameworks/Python.framework/
> >>>>>> Versions/2.5/lib/python2.5/plat-darwin', '/System/Library/
> >>>>>> Frameworks/
> >>>>>> Python.framework/Versions/2.5/lib/python2.5/plat-mac', '/System/
> >>>>>> Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> >>>>>> plat-
> >>>>>> mac/lib-scriptpackages', '/System/Library/Frameworks/
> >>>>>> Python.framework/
> >>>>>> Versions/2.5/Extras/lib/python', '/System/Library/Frameworks/
> >>>>>> Python.framework/Versions/2.5/lib/python2.5/lib-tk', '/System/
> >>>>>> Library/
> >>>>>> Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-
> >>>>>> dynload', '/
> >>>>>> Library/Python/2.5/site-packages', '/System/Library/Frameworks/
> >>>>>> Python.framework/Versions/2.5/Extras/lib/python/PyObjC']
> >>>>>>
> >>>>>> This morning I logged on to my Linux web server and installed all
> >>>>>> these packages from source without any problems.
> >>>>>>
> >>>>>> --S.
> >>>>>>
> >>>>>> _______________________________________________
> >>>>>> Mod_python mailing list
> >>>>>> Mod_python at modpython.org
> >>>>>> http://mailman.modpython.org/mailman/listinfo/mod_python
> >>>>>>
> >>>>
> >>>> _______________________________________________
> >>>> Mod_python mailing list
> >>>> Mod_python at modpython.org
> >>>> http://mailman.modpython.org/mailman/listinfo/mod_python
> >>>>
> >>
> >>
>
>


More information about the Mod_python mailing list