This is not a duplicate of Apache with virtualenv and mod_wsgi : ImportError : No module named 'django' since here I'm not using any virtualenv, and also I'm not trying to import another framework's module (such as django), but just a module in the same directory.
Here is my setup:
/var/www/test/app.py
:
import os, time, sys
from bottle import route, run, template, default_app
os.chdir(os.path.dirname(os.path.abspath(__file__)))
import hello
@route('/')
def index():
return 'Hello world Python ' + sys.version
application = default_app()
/var/www/test/hello.py
:
# just an example module
def test():
print 'hello'
Apache config:
<VirtualHost *:80>
ServerName example.com
<Directory />
Require all granted
</Directory>
WSGIScriptAlias / /var/www/test/app.py
WSGIDaemonProcess test user=www-data group=www-data processes=5 threads=5 display-name=test python-path=/var/www/test/
</VirtualHost>
Then I get:
ImportError: No module named hello
What is incorrect? Shouldn't WSGIDaemonProcess ... python-path=/var/www/test/
help the module hello
to be loaded?
app.py
:os.chdir(os.path.dirname(os.path.abspath(__file__)))
, why is this not enough? – Tenney