【发布时间】:2019-11-28 11:37:41
【问题描述】:
这不是 Apache with virtualenv and mod_wsgi : ImportError : No module named 'django' 的重复,因为我在这里不使用任何 virtualenv,而且我不试图导入另一个框架的模块(例如作为django),但只是一个模块在同一目录中。
这是我的设置:
/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 配置:
<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>
然后我得到:
ImportError: 没有名为 hello 的模块
什么不正确? WSGIDaemonProcess ... python-path=/var/www/test/不应该帮助模块hello被加载吗?
【问题讨论】:
标签: python apache mod-wsgi wsgi