[mod_python] Import problem

Graham Dumpleton graham.dumpleton at gmail.com
Fri Jun 22 18:42:31 EDT 2007


Did you upgrade to mod_python 3.3.1 from an older version at the same time?

There was one incompatible change going to mod_python 3.3.1 from older
versions. This was where the handler directory is no longer put into
sys.path. This doesn't cause any problems if using file based modules
in the same directory, but does if you have a Python package in the
same directory.

Further information can be had by reading the documentation for
apache.import_module() in:

  http://www.modpython.org/live/current/doc-html/pyapi-apmeth.html

If that stuff in the directory is a true Python package with
__init__.py having side affects, then only choice is to move the
directory to outside of the document tree and then use PythonPath
directive to specify where it is located. Other alternative is to
treat your directory as a pseudo package as described in the
documentation.

Anyway, read the documentation and come back if you have more
questions or need something explained.

Graham

On 23/06/07, Olaf Stein <steino at ccri.net> wrote:
> In the folders where cqcb.py is located there is a folder simpla, with a
> file called mod_simpla.py
>
> This same code used to work that's why this is weird
>
>
> On 6/22/07 12:00 PM, "Jim Gallacher" <jpg at jgassociates.ca> wrote:
>
> > Olaf Stein wrote:
> >> Hi all,
> >>
> >> I am running into this really weird problem:
> >> I am on a mac, apache 2.2, mod_python 3.3.1
> >>
> >> I recently upgraded the python version from 2.3.5 to 2.5.1, recompiled
> >> apache and mod_python. This resulted in import errors in my application
> >> (like the one shown below, replacing 2.3 with 2.5).
> >>
> >> As I could not figure out what happened I uninstalled 2.5, recompiled apache
> >> and mod_python with 2.3.5 (basically the setup that was running nicely for a
> >> good while) and now I get the same error.
> >>
> >> Does anyone have any advice, this is driving me nuts.
> >> Thanks in advance
> >> Olaf
> >>
> >>
> >> ----------------
> >> MOD_PYTHON ERROR
> >>
> >> ProcessId:      11732
> >> Interpreter:    'resw87031esw0h.columbuschildrens.net'
> >>
> >> ServerName:     'resw87031esw0h.columbuschildrens.net'
> >> DocumentRoot:   '/usr/local/apache/htdocs'
> >>
> >> URI:            '/apps/cqcb/enter'
> >> Location:       None
> >> Directory:      '/usr/local/apache/htdocs/apps/'
> >> Filename:       '/usr/local/apache/htdocs/apps/cqcb.py'
> >> PathInfo:       '/enter'
> >>
> >> Phase:          'PythonHandler'
> >> Handler:        'mod_python.publisher'
> >>
> >> Traceback (most recent call last):
> >>
> >>   File
> >> "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site
> >> -packages/mod_python/importer.py", line 1537, in HandlerDispatch
> >>     default=default_handler, arg=req, silent=hlist.silent)
> >>
> >>   File
> >> "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site
> >> -packages/mod_python/importer.py", line 1229, in _process_target
> >>     result = _execute_target(config, req, object, arg)
> >>
> >>   File
> >> "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site
> >> -packages/mod_python/importer.py", line 1128, in _execute_target
> >>     result = object(arg)
> >>
> >>   File
> >> "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site
> >> -packages/mod_python/publisher.py", line 204, in handler
> >>     module = page_cache[req]
> >>
> >>   File
> >> "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site
> >> -packages/mod_python/importer.py", line 1059, in __getitem__
> >>     return import_module(req.filename)
> >>
> >>   File
> >> "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site
> >> -packages/mod_python/importer.py", line 296, in import_module
> >>     log, import_path)
> >>
> >>   File
> >> "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site
> >> -packages/mod_python/importer.py", line 680, in import_module
> >>     execfile(file, module.__dict__)
> >>
> >>   File "/usr/local/apache/htdocs/apps/cqcb.py", line 25, in ?
> >>     from simpla.mod_simpla import *
> >>
> >> ImportError: No module named simpla.mod_simpla
> >>
> >
> > Where is the simpla module located? It does exist, right? ;)
> >
> > Jim
> >
> >
>
>
>
>
>
> -------------------------
> Olaf Stein
> DBA
> Center for Quantitative and Computational Biology
> Columbus Children's Research Institute
> 700 Children's Drive
> phone: 1-614-355-5685
> cell: 1-614-843-0432
> email: steino at ccri.net
>
> _______________________________________________
> 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