Python AWS S3-boto3 LibraryNotFoundError HTTPClientError

Python AWS S3-boto3 LibraryNotFoundError HTTPClientError,python,amazon-web-services,amazon-s3,boto3,Python,Amazon Web Services,Amazon S3,Boto3,我试图打印出S3存储桶中的文件。它昨天运行得很好,但不知怎的,我今天得到了LibraryNotFoundError和HTTPClientError(我已经确保安装了boto3库)。如果您能给予指导,我将不胜感激。多谢各位 我的代码: import boto3 s3 = boto3.client('s3', aws_access_key_id='my_access_key',aws_secret_access_key='my_secret_key') bucketname='bucket_name

我试图打印出S3存储桶中的文件。它昨天运行得很好,但不知怎的,我今天得到了
LibraryNotFoundError
HTTPClientError
(我已经确保安装了boto3库)。如果您能给予指导,我将不胜感激。多谢各位

我的代码:

import boto3
s3 = boto3.client('s3', aws_access_key_id='my_access_key',aws_secret_access_key='my_secret_key')
bucketname='bucket_name'
s3_client = boto3.resource('s3')
bucket = s3_client.Bucket(bucketname)

for obj in bucket.objects.all():
    key = obj.key
    print(key)
错误消息:

---------------------------------------------------------------------------
LibraryNotFoundError                      Traceback (most recent call last)
~/opt/anaconda3/lib/python3.7/site-packages/botocore/httpsession.py in send(self, request)
    261                 decode_content=False,
--> 262                 chunked=self._chunked(request.headers),
    263             )

~/opt/anaconda3/lib/python3.7/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    671                 headers=headers,
--> 672                 chunked=chunked,
    673             )

~/opt/anaconda3/lib/python3.7/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    375         try:
--> 376             self._validate_conn(conn)
    377         except (SocketTimeout, BaseSSLError) as e:

~/opt/anaconda3/lib/python3.7/site-packages/urllib3/connectionpool.py in _validate_conn(self, conn)
    993         if not getattr(conn, "sock", None):  # AppEngine might not have  `.sock`
--> 994             conn.connect()
    995 

~/opt/anaconda3/lib/python3.7/site-packages/urllib3/connection.py in connect(self)
    359             server_hostname=server_hostname,
--> 360             ssl_context=context,
    361         )

~/opt/anaconda3/lib/python3.7/site-packages/snowflake/connector/ssl_wrap_socket.py in ssl_wrap_socket_with_ocsp(*args, **kwargs)
    400 
--> 401     from .ocsp_asn1crypto import SnowflakeOCSPAsn1Crypto as SFOCSP
    402 

~/opt/anaconda3/lib/python3.7/site-packages/snowflake/connector/ocsp_asn1crypto.py in <module>
     33             use_openssl(libcrypto_path='/usr/lib/libcrypto.35.dylib', libssl_path='/usr/lib/libssl.35.dylib')
---> 34     from oscrypto import asymmetric
     35 

~/opt/anaconda3/lib/python3.7/site-packages/oscrypto/asymmetric.py in <module>
     18 )
---> 19 from ._asymmetric import _unwrap_private_key_info
     20 from ._errors import pretty_message

~/opt/anaconda3/lib/python3.7/site-packages/oscrypto/_asymmetric.py in <module>
     26 
---> 27 from .kdf import pbkdf1, pbkdf2, pkcs12_kdf
     28 from .symmetric import (

~/opt/anaconda3/lib/python3.7/site-packages/oscrypto/kdf.py in <module>
      8 from . import backend
----> 9 from .util import rand_bytes
     10 from ._types import type_name, byte_cls, int_types

~/opt/anaconda3/lib/python3.7/site-packages/oscrypto/util.py in <module>
      9 if sys.platform == 'darwin':
---> 10     from ._mac.util import rand_bytes
     11 elif sys.platform == 'win32':

~/opt/anaconda3/lib/python3.7/site-packages/oscrypto/_mac/util.py in <module>
     10 from ._common_crypto import CommonCrypto, CommonCryptoConst
---> 11 from ._security import Security
     12 

~/opt/anaconda3/lib/python3.7/site-packages/oscrypto/_mac/_security.py in <module>
      8 if ffi() == 'cffi':
----> 9     from ._security_cffi import Security, version_info as osx_version_info
     10     from ._core_foundation_cffi import CoreFoundation, CFHelpers

~/opt/anaconda3/lib/python3.7/site-packages/oscrypto/_mac/_security_cffi.py in <module>
    238 if not security_path:
--> 239     raise LibraryNotFoundError('The library Security could not be found')
    240 

LibraryNotFoundError: The library Security could not be found

During handling of the above exception, another exception occurred:

HTTPClientError                           Traceback (most recent call last)
<ipython-input-6-4a14fd7aca9a> in <module>
      3 bucket = s3_client.Bucket(bucketname)
      4 
----> 5 for obj in bucket.objects.all():
      6     key = obj.key
      7     print(key)

~/opt/anaconda3/lib/python3.7/site-packages/boto3/resources/collection.py in __iter__(self)
     81 
     82         count = 0
---> 83         for page in self.pages():
     84             for item in page:
     85                 yield item

~/opt/anaconda3/lib/python3.7/site-packages/boto3/resources/collection.py in pages(self)
    164         # we start processing and yielding individual items.
    165         count = 0
--> 166         for page in pages:
    167             page_items = []
    168             for item in self._handler(self._parent, params, page):

~/opt/anaconda3/lib/python3.7/site-packages/botocore/paginate.py in __iter__(self)
    253         self._inject_starting_params(current_kwargs)
    254         while True:
--> 255             response = self._make_request(current_kwargs)
    256             parsed = self._extract_parsed_response(response)
    257             if first_request:

~/opt/anaconda3/lib/python3.7/site-packages/botocore/paginate.py in _make_request(self, current_kwargs)
    330 
    331     def _make_request(self, current_kwargs):
--> 332         return self._method(**current_kwargs)
    333 
    334     def _extract_parsed_response(self, response):

~/opt/anaconda3/lib/python3.7/site-packages/botocore/client.py in _api_call(self, *args, **kwargs)
    355                     "%s() only accepts keyword arguments." % py_operation_name)
    356             # The "self" in this scope is referring to the BaseClient.
--> 357             return self._make_api_call(operation_name, kwargs)
    358 
    359         _api_call.__name__ = str(py_operation_name)

~/opt/anaconda3/lib/python3.7/site-packages/botocore/client.py in _make_api_call(self, operation_name, api_params)
    646         else:
    647             http, parsed_response = self._make_request(
--> 648                 operation_model, request_dict, request_context)
    649 
    650         self.meta.events.emit(

~/opt/anaconda3/lib/python3.7/site-packages/botocore/client.py in _make_request(self, operation_model, request_dict, request_context)
    665     def _make_request(self, operation_model, request_dict, request_context):
    666         try:
--> 667             return self._endpoint.make_request(operation_model, request_dict)
    668         except Exception as e:
    669             self.meta.events.emit(

~/opt/anaconda3/lib/python3.7/site-packages/botocore/endpoint.py in make_request(self, operation_model, request_dict)
    100         logger.debug("Making request for %s with params: %s",
    101                      operation_model, request_dict)
--> 102         return self._send_request(request_dict, operation_model)
    103 
    104     def create_request(self, params, operation_model=None):

~/opt/anaconda3/lib/python3.7/site-packages/botocore/endpoint.py in _send_request(self, request_dict, operation_model)
    135             request, operation_model, context)
    136         while self._needs_retry(attempts, operation_model, request_dict,
--> 137                                 success_response, exception):
    138             attempts += 1
    139             # If there is a stream associated with the request, we need

~/opt/anaconda3/lib/python3.7/site-packages/botocore/endpoint.py in _needs_retry(self, attempts, operation_model, request_dict, response, caught_exception)
    229             event_name, response=response, endpoint=self,
    230             operation=operation_model, attempts=attempts,
--> 231             caught_exception=caught_exception, request_dict=request_dict)
    232         handler_response = first_non_none_response(responses)
    233         if handler_response is None:

~/opt/anaconda3/lib/python3.7/site-packages/botocore/hooks.py in emit(self, event_name, **kwargs)
    354     def emit(self, event_name, **kwargs):
    355         aliased_event_name = self._alias_event_name(event_name)
--> 356         return self._emitter.emit(aliased_event_name, **kwargs)
    357 
    358     def emit_until_response(self, event_name, **kwargs):

~/opt/anaconda3/lib/python3.7/site-packages/botocore/hooks.py in emit(self, event_name, **kwargs)
    226                  handlers.
    227         """
--> 228         return self._emit(event_name, kwargs)
    229 
    230     def emit_until_response(self, event_name, **kwargs):

~/opt/anaconda3/lib/python3.7/site-packages/botocore/hooks.py in _emit(self, event_name, kwargs, stop_on_response)
    209         for handler in handlers_to_call:
    210             logger.debug('Event %s: calling handler %s', event_name, handler)
--> 211             response = handler(**kwargs)
    212             responses.append((handler, response))
    213             if stop_on_response and response is not None:

~/opt/anaconda3/lib/python3.7/site-packages/botocore/retryhandler.py in __call__(self, attempts, response, caught_exception, **kwargs)
    181 
    182         """
--> 183         if self._checker(attempts, response, caught_exception):
    184             result = self._action(attempts=attempts)
    185             logger.debug("Retry needed, action of: %s", result)

~/opt/anaconda3/lib/python3.7/site-packages/botocore/retryhandler.py in __call__(self, attempt_number, response, caught_exception)
    249     def __call__(self, attempt_number, response, caught_exception):
    250         should_retry = self._should_retry(attempt_number, response,
--> 251                                           caught_exception)
    252         if should_retry:
    253             if attempt_number >= self._max_attempts:

~/opt/anaconda3/lib/python3.7/site-packages/botocore/retryhandler.py in _should_retry(self, attempt_number, response, caught_exception)
    267                 attempt_number < self._max_attempts:
    268             try:
--> 269                 return self._checker(attempt_number, response, caught_exception)
    270             except self._retryable_exceptions as e:
    271                 logger.debug("retry needed, retryable exception caught: %s",

~/opt/anaconda3/lib/python3.7/site-packages/botocore/retryhandler.py in __call__(self, attempt_number, response, caught_exception)
    315         for checker in self._checkers:
    316             checker_response = checker(attempt_number, response,
--> 317                                        caught_exception)
    318             if checker_response:
    319                 return checker_response

~/opt/anaconda3/lib/python3.7/site-packages/botocore/retryhandler.py in __call__(self, attempt_number, response, caught_exception)
    221         elif caught_exception is not None:
    222             return self._check_caught_exception(
--> 223                 attempt_number, caught_exception)
    224         else:
    225             raise ValueError("Both response and caught_exception are None.")

~/opt/anaconda3/lib/python3.7/site-packages/botocore/retryhandler.py in _check_caught_exception(self, attempt_number, caught_exception)
    357         # the MaxAttemptsDecorator is not interested in retrying the exception
    358         # then this exception just propogates out past the retry code.
--> 359         raise caught_exception

~/opt/anaconda3/lib/python3.7/site-packages/botocore/endpoint.py in _do_get_response(self, request, operation_model)
    198             http_response = first_non_none_response(responses)
    199             if http_response is None:
--> 200                 http_response = self._send(request)
    201         except HTTPClientError as e:
    202             return (None, e)

~/opt/anaconda3/lib/python3.7/site-packages/botocore/endpoint.py in _send(self, request)
    242 
    243     def _send(self, request):
--> 244         return self.http_session.send(request)
    245 
    246 

~/opt/anaconda3/lib/python3.7/site-packages/botocore/httpsession.py in send(self, request)
    296             message = 'Exception received when sending urllib3 HTTP request'
    297             logger.debug(message, exc_info=True)
--> 298             raise HTTPClientError(error=e)

HTTPClientError: An HTTP Client raised and unhandled exception: The library Security could not be found
---------------------------------------------------------------------------
LibraryNotFoundError回溯(上次最近调用)
发送中的~/opt/anaconda3/lib/python3.7/site-packages/botocore/httpsession.py(self,request)
261解码内容=错误,
-->262 chunked=self.\u chunked(request.headers),
263             )
urlopen中的~/opt/anaconda3/lib/python3.7/site-packages/urllib3/connectionpool.py(self、方法、url、正文、标题、重试、重定向、断言相同的主机、超时、池超时、释放连接、分块、正文位置、**响应)
671页眉=页眉,
-->672分块=分块,
673             )
请求中的~/opt/anaconda3/lib/python3.7/site-packages/urllib3/connectionpool.py(self,conn,method,url,timeout,chunked,**httplib\u request\u kw)
375尝试:
-->376自我验证连接(连接)
377除(SocketTimeout、basessleror)外,如e:
~/opt/anaconda3/lib/python3.7/site-packages/urllib3/connectionpool.py in\u validate\u conn(self,conn)
993如果没有getattr(conn,“sock”,None):#AppEngine可能没有`.sock`
-->994连接件()
995
连接中的~/opt/anaconda3/lib/python3.7/site-packages/urllib3/connection.py(self)
359服务器主机名=服务器主机名,
-->360 ssl_context=上下文,
361         )
~/opt/anaconda3/lib/python3.7/site-packages/snowflake/connector/ssl_-wrap_-socket.py在ssl_-wrap_-socket_中与_-ocsp(*args,**kwargs)
400
-->401来自.ocsp_asn1加密导入雪花ocspasn1crypto作为SFOCSP
402
~/opt/anaconda3/lib/python3.7/site-packages/snowflake/connector/ocsp_asn1crypto.py in
33使用openssl(libcrypto_path='/usr/lib/libcrypto.35.dylib',libssl_path='/usr/lib/libssl.35.dylib')
--->34来自oscrypto公司
35
~/opt/anaconda3/lib/python3.7/site-packages/oscrypto/asymetric.py in
18 )
--->19 from.\u不对称导入\u展开\u私钥\u信息
20发件人。\u错误导入漂亮消息
~/opt/anaconda3/lib/python3.7/site-packages/oscrypto//u.py in
26
--->27从.kdf导入pbkdf1、pbkdf2、pkcs12kdf
28.对称进口(
~/opt/anaconda3/lib/python3.7/site-packages/oscrypto/kdf.py in
8.从后端导入
---->9从.util导入随机字节
10 from.\u类型导入类型\u名称、字节\u cls、int\u类型
~/opt/anaconda3/lib/python3.7/site-packages/oscrypto/util.py in
9如果sys.platform==‘darwin’:
--->10 from.\u mac.util导入随机字节
11 elif sys.platform==“win32”:
~/opt/anaconda3/lib/python3.7/site-packages/oscrypto//u mac/util.py in
10 from.\u common\u crypto导入CommonCrypto,CommonCryptoConst
--->11自.\u安全进口安全
12
~/opt/anaconda3/lib/python3.7/site-packages/oscrypto//u mac//u security.py in
8如果ffi()=“cffi”:
---->9 from.\u security\u cffi导入安全性,版本信息作为osx\u版本信息
10来自.\u core\u foundation\u cffi导入core foundation,CFHelpers
~/opt/anaconda3/lib/python3.7/site-packages/oscrypto//u mac//u security\u cffi.py in
238如果不是安全路径:
-->239 raise LibraryNotFoundError('找不到库安全性')
240
LibraryNotFoundError:找不到库安全性
在处理上述异常期间,发生了另一个异常:
HTTPClientError回溯(最后一次最近调用)
在里面
3 bucket=s3_客户端bucket(bucketname)
4.
---->5表示bucket.objects.all()中的obj:
6键=对象键
7打印(键)
~/opt/anaconda3/lib/python3.7/site-packages/boto3/resources/collection.py in\uuuuu iter\uuuuu(self)
81
82计数=0
--->83对于self.pages()中的页面:
84对于第页中的项目:
85收益项目
页面中的~/opt/anaconda3/lib/python3.7/site-packages/boto3/resources/collection.py(self)
164#我们开始加工和生产单个项目。
165计数=0
-->166页中页:
167页_项=[]
168对于self.\u处理程序中的项(self.\u父项,参数,第页):
~/opt/anaconda3/lib/python3.7/site-packages/botocore/paginate.py in\uuuuu iter\uuuuu(self)
253自注入启动参数(当前参数)
254虽然正确:
-->255响应=自我发出请求(当前请求)
256解析=自。\提取\解析\响应(响应)
257如果第一次请求:
~/opt/anaconda3/lib/python3.7/site-packages/botocore/paginate.py in\u make\u请求(self,current\u kwargs)
330
331定义发出请求(自身、当前请求):
-->332返回自报方法(**当前自报)
333
334 def_extract_parsed_响应(self,response):
调用中的~/opt/anaconda3/lib/python3.7/site-packages/botocore/client.py(self,*args,**kwargs)
355“%s()仅接受关键字参数。“%py\u操作\u名称)
356#此范围中的“自我”指的是BaseClient。
-->357返回self.\u make\u api\u调用(操作名称,kwargs)
358
359\u api\u调用。\u名称\u=str(py\u操作\u名称)
~/opt/anaconda3/lib/python3.7/site-packages/botocore/client.py in\u make\u api\u调用(self、operation\u name、api\u参数)
646其他:
647 http,已解析的\u响应=self.\u发出\u请求(
-->648操作(模型、请求、请求上下文)
649
650 self.meta.events.emit(
~/opt/anaconda3/lib/python3.7/site-packages/botocore/clie