[mod_python] can't import python scripts into my index.py file

Graham Dumpleton graham.dumpleton at gmail.com
Sun Mar 1 01:55:34 EST 2009


Same problems:

  http://www.dscpl.com.au/wiki/ModPython/Articles/ModuleImportingIsBroken

Compile mod_python from source code if binary package is no good.

Graham

2009/3/1 Ron Phelps <rphelps at redshift.com>:
> Graham,
>
> I was wrong as to the mod_python version I have installed at home. I
> have 3.2.10. Does this version have the same import module problems? I
> can't upgrade to 3.3.1 as it requires a version of libc6 that is not
> compatible with just about everything else on my system.
>
> Thanks again,
>
> Ron
>
> On Sun, 2009-03-01 at 15:45 +1100, Graham Dumpleton wrote:
>> 2009/3/1 Ron Phelps <rphelps at redshift.com>:
>> > I have similar mod_python setups at work and home. The differences are
>> > at work the setup is Ubuntu Gutsy and at home I have Ubuntu Feisty so
>> > the home installation uses 3.2 mod_python and the work 3.3. The other
>> > difference is at home I have apache2 configured for two virtual
>> > websites. The work installation is only one website.
>> >
>> > The problem is I can't import python scripts from index.py on my home
>> > installation but I have no problem at work. Scripts in both
>> > installations are in the home directory of the website.
>> >
>> > -------------------
>> > Code example from work, index.py uses a href link to call the following
>> > python script all imports work eps_extract is python script in the same
>> > directory as index.py
>> >
>> > from cgi import escape
>> > from urllib import unquote
>> >
>> > #Import database and plotting functions
>> > from select import select
>> > import eps_extract
>> >
>> > def frame():
>> >
>> >        s = """\
>> >        ...
>> >        html code here
>> >        ..."""
>> >
>> >    return s
>> >
>> > def plots():
>> >
>> >        etc ...
>> >
>> > ------------------------
>> > Code example from home - index.py:
>> > I have tried simply using the import statement as above
>> > and like below. The scripts weatherstation and pexpect are in the same
>> > directory as index.py
>> >
>> > import sys, os
>> > from mod_python import apache
>> > weatherstation = apache.import_module("weatherstation")
>> > pexpect  = apache.import_module("pexpect")
>> >
>> > Mod_python returns
>> >
>> > ImportError: No module named weatherstation
>> >
>> >
>> > Thanks for any help you can give.
>>
>> Simple, upgrade your home machine so it matches the latest version of
>> mod_python (3.3.1) used at work.
>>
>> The module importer has lots of problems in the older version and you
>> really do not want to use it.
>>
>> Once you have upgraded and use same version on both, then read the
>> documentation. Specifically that for import_module() in:
>>
>>   http://www.modpython.org/live/current/doc-html/pyapi-apmeth.html
>>
>> Graham
>>
>>
>> Graham
>>
>
>



More information about the Mod_python mailing list