在EC2 ubuntu上的Flask中导入pandas(和其他模块)会出错

时间:2013-11-03 21:25:08

标签: python amazon-ec2 pandas flask

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

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

enter image description here

我的 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'。 / p>

现在我取消注释 pandas requests ,服务器/烧瓶端的一切运行正常:

 * 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

0 个答案:

没有答案