在 apache 上 运行 时 Boto 导入错误

Boto Import Error when running on apache

我有一个 AWS EC2 实例 运行 一个通过 apache 的烧瓶应用程序。

我已经通过 pip 安装了 boto

我已经设置了一个 wsgi 文件,如果我的 flask 应用程序是一个简单的 hello world,它就可以正常工作:

#This works
from flask import Flask

app = Flask(__name__)

@app.route("/hello")
def hello():
    return "Hello World"

if __name__ == "__main__":
    app.run(host='0.0.0.0',port=80)

#http://<PUBLIC_IP>.ap-southeast-2.compute.amazonaws.com/hello
#Hello World

但是如果我尝试导入 boto:

from boto import dynamodb2 from boto.dynamodb2.table import Table

当我访问 http://.ap-southeast-2.compute.amazonaws.com/hello 我收到内部服务器错误。检查日志显示这个

[Thu Aug 06 03:20:50 2015] [error] [client 203.220.19.142] mod_wsgi (pid=2988): Target WSGI script '/var/www/myservice/myservice.wsgi' cannot be loaded as Python module.
[Thu Aug 06 03:20:50 2015] [error] [client 203.220.19.142] mod_wsgi (pid=2988): Exception occurred processing WSGI script '/var/www/myservice/myservice.wsgi'.
[Thu Aug 06 03:20:50 2015] [error] [client 203.220.19.142] Traceback (most recent call last):
[Thu Aug 06 03:20:50 2015] [error] [client 203.220.19.142]   File "/var/www/myservice/myservice.wsgi", line 4, in <module>
[Thu Aug 06 03:20:50 2015] [error] [client 203.220.19.142]     from myservice import app as application
[Thu Aug 06 03:20:50 2015] [error] [client 203.220.19.142]   File "/var/www/myservice/myservice.py", line 6, in <module>
[Thu Aug 06 03:20:50 2015] [error] [client 203.220.19.142]     from boto import dynamodb2
[Thu Aug 06 03:20:50 2015] [error] [client 203.220.19.142] ImportError: No module named boto

尽管我已经安装了 boto (pip install boto)

我该如何解决这个问题?

我在 yum 中搜索了相关内容,然后 运行:

yum install python26-boto.noarch

我解决了这个问题