flask,mod_wsgi,apache:Importerror:

时间:2014-04-09 16:57:21

标签: python apache flask wsgi

我在使用wsgi在apache2上部署烧瓶应用程序时遇到问题。我想我已经尝试过在这个网站上提出的每个解决方案,但没有任何帮助。每个输入或建议都表示赞赏。

这是我的文件和日志

apache conf

WSGIScriptAlias /wsgi D:/microblog/test/wsgi.py
<Directory D:/microblog/test>
AllowOverride None
Options None
Order deny,allow
Allow from all
</Directory>

wsgi.py

import sys
from test import app as application


sys.path.insert(0, 'D:/microblog/test')

_ 初始化 _。PY

from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
import sys

app = Flask(__name__)
app.config.from_pyfile("app_config.py")
app.debug = True 

@app.route('/')
def hello_world():
    return "hi"

app.run()

apache日志

[Wed Apr 09 09:52:27 2014] [error] [client 127.0.0.1] mod_wsgi (pid=3368): 
Exception occurred processing WSGI script 'D:/microblog/test/wsgi.py'.
[Wed Apr 09 09:52:27 2014] [error] [client 127.0.0.1] Traceback (most recent call     last):
[Wed Apr 09 09:52:27 2014] [error] [client 127.0.0.1]   File "D://microblog/test/wsgi.py", line 2, in <module>
[Wed Apr 09 09:52:27 2014] [error] [client 127.0.0.1]     from test import app as application
[Wed Apr 09 09:52:27 2014] [error] [client 127.0.0.1] ImportError: cannot import name app

谢谢!

1 个答案:

答案 0 :(得分:0)

在Apache配置中使用WSGIPythonPath指令告诉mod_wsgi您的项目代码在哪里。不知道你的代码结构,但试试:

 WSGIPythonPath /microblog/test