【发布时间】:2014-02-13 22:00:18
【问题描述】:
我正在尝试使用 boto 库访问 amazon s3 以访问 amazon 'aws-publicdatasets' 中可用的常见爬网数据。
我在 ~/.boto 中创建了访问配置文件
[Credentials]
aws_access_key_id = "my key"
aws_secret_access_key = "my_secret"
在创建与 amazon s3 的连接时,我在日志中看到以下错误。
2014-01-23 16:28:16,318 boto [DEBUG]:Retrieving credentials from metadata server.
2014-01-23 16:28:17,321 boto [ERROR]:Caught exception reading instance data
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/boto-2.13.3-py2.6.egg/boto/utils.py", line 211, in retry_url
r = opener.open(req)
File "/usr/lib64/python2.6/urllib2.py", line 391, in open
response = self._open(req, data)
File "/usr/lib64/python2.6/urllib2.py", line 409, in _open
'_open', req)
File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
result = func(*args)
File "/usr/lib64/python2.6/urllib2.py", line 1190, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib64/python2.6/urllib2.py", line 1165, in do_open
raise URLError(err)
URLError: <urlopen error timed out>
2014-01-23 16:28:17,323 boto [ERROR]:Unable to read instance data, giving up
以其他方式,我尝试在创建连接对象时提供凭据,如下所示
from boto.s3.connection import S3Connection
from boto.s3.bucket import Bucket
boto.set_stream_logger('boto')
connection = S3Connection('______','__________')
bucket = Bucket(connection.get_bucket('aws-publicdatasets'))
我仍然在日志中看到同样的错误
【问题讨论】:
-
使用
bucket = connection.get_bucket('aws-publicdatasets'),你的代码对我来说很好。也许有什么东西阻止了你的请求(防火墙?)。 -
谢谢@andpei。但我的防火墙已关闭。连接到 s3 时出现错误。我用 3 行代码执行了程序:
import boto boto.set_stream_logger('boto') conn = boto.connect_s3(anon=True)但仍然看到错误 -
我遇到了同样的错误,你解决了吗?
-
这里也一样。只需执行 connect_s3(anon=True) 就足以让库打印错误消息。
标签: python-2.7 boto