Apache2 / mod_wsgi导致导入错误

时间:2016-02-09 23:03:36

标签: python apache python-3.x flask mod-wsgi

现在这真让我烦恼。

我正在尝试通过mod_wsgi和Apache服务器将我的Flask应用程序部署到我的Ubuntu VPS。

每当我启动Apache服务器时,它似乎运行得很好。但是,每当我尝试转到我的VPS网址时,都会收到500内部服务器错误。

在查看/var/log/apache2/error.log时,我看到了这一点:

Loading WSGI script '/var/www/Giveaways/giveaways.wsgi'.
Target WSGI script '/var/www/Giveaways/giveaways.wsgi' cannot be loaded as Python module.
Exception occurred processing WSGI script '/var/www/Giveaways/giveaways.wsgi'.
Traceback (most recent call last):
  File "/var/www/Giveaways/giveaways.wsgi", line 7, in <module>
    from Giveaways import application as application
  File "/var/www/Giveaways/Giveaways/__init__.py", line 3, in <module>
    from flask import Flask, request
ImportError: No module named 'flask'

这是giveaways.wsgi文件:

#!/usr/bin/python3.5

activate_this = '/var/www/Giveaway/Giveaway/venv3-5/bin/activate_this.py'
with open(activate_this) as f:
    code = compile(f.read(), "somefile.py", 'exec')
    exec(code)

import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/Giveaways/")

from Giveaways import application
application.secret_key = 'Add your secret key'

奇怪的是,即使我安装了3个版本的Python(2.7,3.4和3.50,它们都安装了烧瓶包,所以这个问题让我感到难过。

非常感谢帮助。

0 个答案:

没有答案