Flask, mod_wsgi, and Apache: ImportError

一曲冷凌霜 提交于 2019-12-04 03:11:56

If you're deploying a virtualenv, you'll have to make sure to activate it first. You should update your wsgi file like this (updating the values to match your environment):

activate_this = '/path/to/virtualenv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this)

import sys
sys.path.insert(0, '/path/to/flask/appname')
sys.path.insert(0,'/home/ec2-user/hatemail')
sys.path.insert(1,'/home/ec2-user')

from badassery import app as application

If you aren't deploying a virtualenv, you probably just need to make sure that Flask is installed on your system. If you've already installed setuptools you can just:

easy_install flask
user2099484

If you have any problems with importing when using wsgi_mod, make sure you try explicitly pointing to the import files that are causing problems:

sys.path.append('/home/foo/www/Forms')

then do your import!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!