1

我有一个 Ubuntu 12.04.3 LTS EC2 实例(我已经安装了 apache、java 等)并且有一个 Anaconda/Python 的工作版本。

我还设置了烧瓶(在 apache 后面运行)并设置了一个虚拟主机。我为烧瓶设置了以下目录:

在此处输入图像描述

我的init .py文件非常简单:

from __future__ import division

import string
import datetime
import json
import xml.etree.ElementTree as ET

from flask import Flask, jsonify
from flask import abort

#import pandas as pd
#import requests

app = Flask(__name__)

@app.route("/")

def hello():
    return "test6"

if __name__ == "__main__":
    app.run()

然后,在运行python init .py之后,当我到达我的 EC2 实例公共地址时,一切都很好,并且我收到了预期的消息“test6”。

现在我取消注释pandasrequests,服务器/烧瓶端的所有内容都可以正常运行:

 * Running on http://127.0.0.1:5000/

当我运行时:

curl http://127.0.0.1:5000/

我得到了我所期望的(即'test6')。

但是当我导航到同一个 EC2 公共 URL 时,我得到:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, admin@mywebsite.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Apache/2.2.22 (Ubuntu) Server at ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com Port 80

有谁知道发生了什么?我只是导入两个模块,我可以从 python 的命令行版本导入它们(而且整个设置在我的 mac 上本地运行良好)。

也许它的内存不足,因为它的小实例?

提前感谢您的帮助!

编辑:只需查看 apache 服务器日志(error.log):

[Sun Nov 03 21:48:56 2013] [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
[Sun Nov 03 21:49:51 2013] [notice] caught SIGTERM, shutting down
[Sun Nov 03 21:49:52 2013] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Sun Nov 03 21:49:52 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Sun Nov 03 21:49:52 2013] [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
[Sun Nov 03 21:50:02 2013] [error] [client xx.xxx.xxx.xx] mod_wsgi (pid=6874): Target WSGI script '/var/www/microblog/microblog.wsgi' cannot be loaded as Python module.
[Sun Nov 03 21:50:02 2013] [error] [client xx.xxx.xxx.xx] mod_wsgi (pid=6874): Exception occurred processing WSGI script '/var/www/microblog/microblog.wsgi'.
[Sun Nov 03 21:50:02 2013] [error] [client xx.xxx.xxx.xx] Traceback (most recent call last):
[Sun Nov 03 21:50:02 2013] [error] [client xx.xxx.xxx.xx]   File "/var/www/microblog/microblog.wsgi", line 7, in <module>
[Sun Nov 03 21:50:02 2013] [error] [client xx.xxx.xxx.xx]     from app import app as application
[Sun Nov 03 21:50:02 2013] [error] [client xx.xxx.xxx.xx]   File "/var/www/microblog/app/__init__.py", line 11, in <module>
[Sun Nov 03 21:50:02 2013] [error] [client xx.xxx.xxx.xx]     import pandas as pd
[Sun Nov 03 21:50:02 2013] [error] [client xx.xxx.xxx.xx] ImportError: No module named pandas
[Sun Nov 03 21:50:03 2013] [error] [client xx.xxx.xxx.xx] mod_wsgi (pid=6873): Target WSGI script '/var/www/microblog/microblog.wsgi' cannot be loaded as Python module.
[Sun Nov 03 21:50:03 2013] [error] [client xx.xxx.xxx.xx] mod_wsgi (pid=6873): Exception occurred processing WSGI script '/var/www/microblog/microblog.wsgi'.
[Sun Nov 03 21:50:03 2013] [error] [client xx.xxx.xxx.xx] Traceback (most recent call last):
[Sun Nov 03 21:50:03 2013] [error] [client xx.xxx.xxx.xx]   File "/var/www/microblog/microblog.wsgi", line 7, in <module>
[Sun Nov 03 21:50:03 2013] [error] [client xx.xxx.xxx.xx]     from app import app as application
[Sun Nov 03 21:50:03 2013] [error] [client xx.xxx.xxx.xx]   File "/var/www/microblog/app/__init__.py", line 11, in <module>
[Sun Nov 03 21:50:03 2013] [error] [client xx.xxx.xxx.xx]     import pandas as pd
[Sun Nov 03 21:50:03 2013] [error] [client xx.xxx.xxx.xx] ImportError: No module named pandas
4

0 回答 0