简体   繁体   中英

flask, mod_wsgi, apache: Importerror:

I am having an issue deploying a flask app on apache2 using wsgi. I guess i have already tried every solution proposed on this site, but nothing has helped. Every input or suggestions are appreciated.

Here are my files and logs

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')

_ init _.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 log

[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

thanks!

Use WSGIPythonPath directive in Apache configuration to tell mod_wsgi where your project code is. Don't know your code structure, but try:

 WSGIPythonPath /microblog/test

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM