我在使用 wsgi 在 apache2 上部署 flask 应用程序时遇到问题。我想我已经尝试过该站点上提出的所有解决方案,但没有任何帮助。感谢每一个输入或建议。
这是我的文件和日志
apache 配置
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
谢谢!
最佳答案
在 Apache 配置中使用 WSGIPythonPath 指令告诉 mod_wsgi 你的项目代码在哪里。不知道您的代码结构,但请尝试:
WSGIPythonPath /microblog/test
关于python - flask ,mod_wsgi,apache : Importerror:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22969161/