python mrjob - gaierror:[Errno -2]名称或服务未知

时间:2013-07-03 22:04:52

标签: python amazon-s3 emr mrjob

我正在尝试从mrjob模块访问s3文件。 这是失败的代码:

from mrjob.emr import S3Filesystem
fs = S3Filesystem("<aws_access_key_id>", "<aws_secret_access_key>", "us-west-2")
fs.get_s3_key("s3n://<bucket>/<folder>/file.txt")

(但是使用实际的aws_access_key_id,aws_secret_access_key,存储桶和文件夹),我得到的错误是:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/mrjob/fs/s3.py", line 235, in get_s3_key
    bucket = s3_conn.get_bucket(bucket_name)
  File "/usr/local/lib/python2.7/dist-packages/mrjob/retry.py", line 80, in call_and_maybe_retry
    return f(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/boto/s3/connection.py", line 431, in get_bucket
    bucket.get_all_keys(headers, maxkeys=0)
  File "/usr/local/lib/python2.7/dist-packages/boto/s3/bucket.py", line 375, in get_all_keys
    '', headers, **params)
  File "/usr/local/lib/python2.7/dist-packages/boto/s3/bucket.py", line 332, in _get_all
    query_args=query_args)
  File "/usr/local/lib/python2.7/dist-packages/boto/s3/connection.py", line 547, in make_request
    retry_handler=retry_handler
  File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 947, in make_request
    retry_handler=retry_handler)
  File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 908, in _mexe
    raise e
gaierror: [Errno -2] Name or service not known

有什么建议吗? 谢谢!

1 个答案:

答案 0 :(得分:-1)

这(s3n://)

fs.get_s3_key("s3n://<bucket>/<folder>/file.txt")

应该是这个(s3://):

fs.get_s3_key("s3://<bucket>/<folder>/file.txt")