apache says: ImportError: No module named ladon.server.wsgi

Asked by oyzzo on 2011-10-13

Hi,
I've been following the examples on the web and they work fine using ladonX.Yctl.
As i need to serve my webservices as production state i've installed mod_wsgi on apache and it's working fine too serving some test python apps, but when i want to use it to serve a ladon webservice app i get this error from apache:

[Thu Oct 13 12:41:26 2011] [error] [client 127.0.0.1] mod_wsgi (pid=2277): Target WSGI script '/srv/http/ladon/calculator/handler.py' cannot be loaded as Python module.
[Thu Oct 13 12:41:26 2011] [error] [client 127.0.0.1] mod_wsgi (pid=2277): Exception occurred processing WSGI script '/srv/http/ladon/calculator/handler.py'.
[Thu Oct 13 12:41:26 2011] [error] [client 127.0.0.1] Traceback (most recent call last):
[Thu Oct 13 12:41:26 2011] [error] [client 127.0.0.1] File "/srv/http/ladon/calculator/handler.py", line 2, in <module>
[Thu Oct 13 12:41:26 2011] [error] [client 127.0.0.1] from ladon.server.wsgi import LadonWSGIApplication
[Thu Oct 13 12:41:26 2011] [error] [client 127.0.0.1] ImportError: No module named ladon.server.wsgi

apache seems not to find the module, but when i run the python interactive console and i type the import on it, it works fine, so the module is correctly installed.

for the tests i'm using the add method example you have on the web.

I can't figure out what's wrong, I need some help please.

Question information

Language:
English Edit question
Status:
Solved
For:
ladon Edit question
Assignee:
No assignee Edit question
Solved by:
oyzzo
Solved:
2011-10-18
Last query:
2011-10-18
Last reply:
2011-10-15
jsgaarde (jakob-simon-gaarde) said : #1

Hi oyzzo.

Can you please post your handler:
/srv/http/ladon/calculator/handler.py

Best Regards
Jakob Simon-Gaarde

jsgaarde (jakob-simon-gaarde) said : #2

Hi oyzzo.

Finally weekend, so I have better time to respond to your question.
The configuration example at http://www.ladonize.org/index.php/Python_Configuration should work, cause I remember testing it when I wrote it.
From the exception you get it seems like the python interpreter spawned by mod_wsgi does not have module search path to Ladon. You can test what module path your interpreter has in mod_wsgi with this script:

http://paste.ubuntu.com/708457/

I am guessing you are using Python 2, if not you will have to alter the script.

Best regards Jakob Simon-Gaarde

oyzzo (oyzzoforfree) said : #3

Hi jsgaarde,

I tested the example at http://www.ladonize.org/index.php/Python_Configuration and it didn't work neither.

The computer where i had the problem was an old test computer with python 3, not the production server i'm using for the webservices. I tried on the production server where i have python 2.7 and everything is running perfect, so for me the problem is solved.

You've been very kind, thanks a lot for your help.
:)