使用mod_wsgi httpd和Flask应用程序导入错误

时间:2016-12-14 01:07:07

标签: python apache flask jinja2 mod-wsgi

好的,这是我有人试图访问服务器时收到的错误。 (来自error_log)

错误

---
title: "Biblio Example"
output: html_document
bibliography: bibliography.bib
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Here's Some Text

This text cites the paper:  [@Vahid_Jalili_Musera_2015].

## References

The bibliography will appear by magic at the end of the document, just
below this text.

我的目录

quicksearch.py​​是主要的应用程序,其余的是网站的HTML等

[Wed Dec 14 11:49:12 2016] [error] [client 10.0.2.15] mod_wsgi (pid=19122): Target WSGI script '/var/www/QuickSearch/quicksearch.wsgi' cannot be loaded as Python module.
[Wed Dec 14 11:49:12 2016] [error] [client 10.0.2.15] mod_wsgi (pid=19122): Exception occurred processing WSGI script '/var/www/QuickSearch/quicksearch.wsgi'.
[Wed Dec 14 11:49:12 2016] [error] [client 10.0.2.15] Traceback (most recent call last):
[Wed Dec 14 11:49:12 2016] [error] [client 10.0.2.15]   File "/var/www/QuickSearch/quicksearch.wsgi", line 12, in <module>
[Wed Dec 14 11:49:12 2016] [error] [client 10.0.2.15]     from quicksearch import app
[Wed Dec 14 11:49:12 2016] [error] [client 10.0.2.15]   File "/var/www/QuickSearch/QuickSearch/quicksearch.py", line 5, in <module>
[Wed Dec 14 11:49:12 2016] [error] [client 10.0.2.15]     from flask import Flask
[Wed Dec 14 11:49:12 2016] [error] [client 10.0.2.15]   File "/usr/lib/python2.6/site-packages/flask/__init__.py", line 19, in <module>
[Wed Dec 14 11:49:12 2016] [error] [client 10.0.2.15]     from jinja2 import Markup, escape
[Wed Dec 14 11:49:12 2016] [error] [client 10.0.2.15] ImportError: No module named jinja2

quicksearch.wsgi

/var/www/QuickSearch/
|-- QuickSearch
|   |-- __init__.py
|   |-- quicksearch.py
|   |-- static
|   |   |-- css
|   |   |-- fonts
|   |   `-- js
|   `-- templates
`-- quicksearch.wsgi

quicksearch.conf

这是服务器的配置文件

#!/usr/bin/env /usr/prod/mts/platform/sandboxes/rhel6/mts-build-09/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)

activate_this = '/var/www/QuickSearch/QuickSearch/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))

sys.path.insert(0,"/var/www/QuickSearch/QuickSearch/")
sys.path.append("/var/www/QuickSearch/")

from quicksearch import app as application

我完全失去了,我已经尝试解决这个问题两天了,不知道下一步该做什么。我已经看过类似的线索,仍然没有找到解决方案。如果您需要任何信息来帮助解决这个问题,请发布。谢谢。

1 个答案:

答案 0 :(得分:0)

您的mod_wsgi是为Python 2.6编译的。您无法使用Python 2.7强制它使用Python虚拟环境。这在Python虚拟环境的mod_wsgi文档中有解释:

您需要安装为Python 2.7编译的mod_wsgi版本。