我编写了以下代码来使用boto创建AWS S3存储桶: -
from boto.s3.connection import S3Connection
conn = S3Connection()
bucket = conn.create_bucket('mybucket1')
但是当我运行此代码时,我收到以下错误: -
Traceback (most recent call last):
File "prob1.py", line 3, in <module>
bucket = conn.create_bucket('mybucket1')
File "/usr/local/lib/python2.7/dist-packages/boto/s3/connection.py", line 619, in create_bucket
data=data)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/connection.py", line 671, in make_request
retry_handler=retry_handler
File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 1071, in make_request
retry_handler=retry_handler)
File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 913, in _mexe
self.is_secure)
File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 705, in get_http_connection
return self.new_http_connection(host, port, is_secure)
File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 747, in new_http_connection
connection = self.proxy_ssl(host, is_secure and 443 or 80)
File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 792, in proxy_ssl
int(self.proxy_port)), timeout)
File "/usr/lib/python2.7/socket.py", line 575, in create_connection
raise err
socket.timeout: timed out
我没有使用任何代理服务器。 帮我调试一下这段代码。谢谢。
答案 0 :(得分:1)
你的代码非常好。
错误是超时,这表示存在网络问题,例如端口被公司IT阻止。
从其他网络(例如从家中)尝试,您会发现它可以正常工作。然后是追踪运行网络的人来找出阻碍连接的因素。
或者,创建一个Amazon EC2实例,连接到它(如果可能的话),然后从那里运行代码。