Reputation: 800
I am created an api for OpenERP using bottle and when i try to configure wsgi with apache.
While importing in apache server log it shows
ImportError: No module named api
I checked for current directory it prints cwd and the import file is in same directory still it shows error
Here i uploaded my code for wsgi
import os
os.chdir(os.path.dirname(__file__))
import bottle
print os.getcwd()
import api as application
application = bottle.defaut_app()
Upvotes: 0
Views: 610
Reputation: 18148
What is your sys.path
?
It must include the directory of your .py
file, not the file name itself. E.g.,
sys.path.append('/var/www/api')
# and then, to see its new value:
print sys.path.append
Also note how I printed the value of sys.path there; the way you did it in one of your comments (printing the return value from append
) is incorrect.
Upvotes: 1
Reputation: 1116
I think i had a similar problem and I ended up doing this in my wsgi:
import sys
import os
import bottle
sys.path.append('%path to module%')
import %modulename%
application = bottle.default_app()
In your py you have to import:
from bottle import default_app
for this to work.
Upvotes: 0