473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Error importing modules with mod_python

I've installed mod_python, and everything seems to be working, but it
fails when I try to import another file into the file that's actually
producing the output. I have these lines at the top of index.py:

from mod_python import apache
from storylab import *

.... and in the directory where index.py resides (/htdocs/python/), I
have a directory called "storylab". Inside that directory is
__init__.py. When I try to execute /htdocs/python/index.py, I get the
following error:

---

MOD_PYTHON ERROR
ProcessId: 828
Interpreter: 'localhost'
ServerName: 'localhost'
DocumentRoot: 'C:/htdocs'
URI: '/python/index.py'
Location: None
Directory: 'C:/htdocs/python/'
Filename: 'C:/htdocs/python/index.py'
PathInfo: ''
Phase: 'PythonHandler'
Handler: 'index'

Traceback (most recent call last):

File "C:\Python25\lib\site-packages\mod_python\importer.py", line
1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)

File "C:\Python25\lib\site-packages\mod_python\importer.py", line
1202, in _process_target
module = import_module(module_name, path=path)

File "C:\Python25\lib\site-packages\mod_python\importer.py", line
296, in import_module
log, import_path)

File "C:\Python25\lib\site-packages\mod_python\importer.py", line
680, in import_module
execfile(file, module.__dict__)

File "C:\htdocs\python\index.py", line 2, in <module>
from storylab import *

ImportError: No module named storylab

---

What am I doing wrong? Any insight would be greatly appreciated.

Thanks,
Aaron
Jul 21 '08 #1
2 2028
Aaron Scott wrote:
I've installed mod_python, and everything seems to be working, but it
fails when I try to import another file into the file that's actually
producing the output. I have these lines at the top of index.py:

from mod_python import apache
from storylab import *

... and in the directory where index.py resides (/htdocs/python/), I
have a directory called "storylab". Inside that directory is
__init__.py. When I try to execute /htdocs/python/index.py, I get the
following error:

---

MOD_PYTHON ERROR
ProcessId: 828
Interpreter: 'localhost'
ServerName: 'localhost'
DocumentRoot: 'C:/htdocs'
URI: '/python/index.py'
Location: None
Directory: 'C:/htdocs/python/'
Filename: 'C:/htdocs/python/index.py'
PathInfo: ''
Phase: 'PythonHandler'
Handler: 'index'

Traceback (most recent call last):

File "C:\Python25\lib\site-packages\mod_python\importer.py", line
1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)

File "C:\Python25\lib\site-packages\mod_python\importer.py", line
1202, in _process_target
module = import_module(module_name, path=path)

File "C:\Python25\lib\site-packages\mod_python\importer.py", line
296, in import_module
log, import_path)

File "C:\Python25\lib\site-packages\mod_python\importer.py", line
680, in import_module
execfile(file, module.__dict__)

File "C:\htdocs\python\index.py", line 2, in <module>
from storylab import *

ImportError: No module named storylab

---

What am I doing wrong? Any insight would be greatly appreciated.
You need to tell python that it should add the path your storylab-module is
residing in to the sys.path-list of module locations.

There are a bunch of ways to do so:

- in your main-script, import sys, and append the proper path to sys.path
- add a .pth-file into python's site-packages that points to the location
- set the environment variable PYTHONPATH
- use distutils or setuptools to proper install the module.

Google will help you to find additional information about the above
mentioned concepts.

Diez
Jul 21 '08 #2
On Jul 22, 3:30*am, Aaron Scott <aaron.hildebra...@gmail.comwrote:
I've installedmod_python, and everything seems to be working, but it
fails when I try to import another file into the file that's actually
producing the output. I have these lines at the top of index.py:

frommod_pythonimport apache
from storylab import *

... and in the directory where index.py resides (/htdocs/python/), I
have a directory called "storylab". Inside that directory is
__init__.py. When I try to execute /htdocs/python/index.py, I get the
following error:

---

MOD_PYTHONERROR
ProcessId: * * *828
Interpreter: * *'localhost'
ServerName: * * 'localhost'
DocumentRoot: * 'C:/htdocs'
URI: * * * * * *'/python/index.py'
Location: * * * None
Directory: * * *'C:/htdocs/python/'
Filename: * * * 'C:/htdocs/python/index.py'
PathInfo: * * * ''
Phase: * * * * *'PythonHandler'
Handler: * * * *'index'

Traceback (most recent call last):

* File "C:\Python25\lib\site-packages\mod_python\importer.py", line
1537, in HandlerDispatch
* * default=default_handler, arg=req, silent=hlist.silent)

* File "C:\Python25\lib\site-packages\mod_python\importer.py", line
1202, in _process_target
* * module = import_module(module_name, path=path)

* File "C:\Python25\lib\site-packages\mod_python\importer.py", line
296, in import_module
* * log, import_path)

* File "C:\Python25\lib\site-packages\mod_python\importer.py", line
680, in import_module
* * execfile(file, module.__dict__)

* File "C:\htdocs\python\index.py", line 2, in <module>
* * from storylab import *

ImportError: No module named storylab

---

What am I doing wrong? Any insight would be greatly appreciated.
You can't put Python packages in same directory as handler scripts
managed by mod_python. See documentation for import_module() in:

http://www.modpython.org/live/curren...pi-apmeth.html

Graham
Jul 22 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Lorenz Köhl | last post by:
hi, I've python 2.3 and apache 2.0.47 installed on my SuSE8.2. when trying to compile modpython into apache, make stops with the error ---- In file included from...
4
by: Michele Petrazzo | last post by:
I'm using PyChart like a module for create charts into a little web site, but when I try to create one, I have this error: /var/www/html/lgt/draw.py:19, in draw: can =...
0
by: Julien Cigar | last post by:
Hello, I'm using mod_python 3.1.3 with Apache 2.0.54 on a Debian box with the publisher handler and the Clearsilver template engine, and from time to time apache returns an 500 error code...
1
by: jcharth | last post by:
Hello for somereason when i execute php files in folder other than the document root, i get error 500 and the php file is downloaded to my browser with the 500 error code. I think it could be...
4
by: Mark | last post by:
Good morning. I recently made some changes to my Access project, and I introduced some problems that I could not resolve. So I deleted the forms that I had altered and saved the project. Then I...
14
by: T. Crane | last post by:
Hi, When troubleshooting code that's saved in a text file, I often find that I want to make a change to it, re-save it, then reimport it. However, just typing import myTestCode doesn't...
1
by: deepak | last post by:
I installed apache 2.2.4 and modPython 3.3.1 on Fc6 while starting the apache server the following error occurs: httpd: Syntax error on line 54 of /usr/local/apache2/conf/httpd.conf: Cannot load...
3
by: Paul Rudin | last post by:
I'm occasionally seeing tracebacks like this: Traceback (most recent call last): File "logging/__init__.py", line 744, in emit File "logging/__init__.py", line 630, in format File...
0
by: Martin P. Hellwig | last post by:
Hello all, I had some troubles in the past how to arrange my packages and modules, because I usually don't develop my stuff in the Lib\site-packages directory I have some troubles when importing...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.