Boto3.client或boto3.resource抛出“模块”对象没有属性“ _Condition”错误

时间:2019-05-17 20:18:17

标签: python python-2.7 amazon-s3 boto3

我正在尝试使用boto3从python代码访问s3存储桶。当执行到达boto3.client('s3')时,抛出属性错误:模块对象没有属性'_Condition'错误

我尝试使用boto3.resource和boto3.client读取s3存储桶对象。两者都抛出错误

import sys
sys.path.append('')
import boto3
s3 = boto3.resource('s3')
client = boto3.client('s3')

请找到堆栈跟踪:

com.streamsets.pipeline.api.StageException: SCRIPTING_06 - Script error while processing batch: javax.script.ScriptException: AttributeError: 'module' object has no attribute '_Condition' in <script> at line number 9
    at com.streamsets.pipeline.stage.processor.scripting.AbstractScriptingProcessor.runScript(AbstractScriptingProcessor.java:256)
    at com.streamsets.pipeline.stage.processor.scripting.AbstractScriptingProcessor.runBatch(AbstractScriptingProcessor.java:237)
    at com.streamsets.pipeline.stage.processor.scripting.AbstractScriptingProcessor.process(AbstractScriptingProcessor.java:214)
    at com.streamsets.pipeline.api.base.SingleLaneProcessor.process(SingleLaneProcessor.java:95)
    at com.streamsets.pipeline.api.base.configurablestage.DProcessor.process(DProcessor.java:35)
    at com.streamsets.datacollector.runner.StageRuntime.lambda$execute$2(StageRuntime.java:286)
    at com.streamsets.datacollector.runner.StageRuntime.execute(StageRuntime.java:235)
    at com.streamsets.datacollector.runner.StageRuntime.execute(StageRuntime.java:298)
    at com.streamsets.datacollector.runner.StagePipe.process(StagePipe.java:219)
    at com.streamsets.datacollector.execution.runner.common.ProductionPipelineRunner.processPipe(ProductionPipelineRunner.java:810)
    at com.streamsets.datacollector.execution.runner.common.ProductionPipelineRunner.lambda$executeRunner$3(ProductionPipelineRunner.java:854)
    at com.streamsets.datacollector.runner.PipeRunner.acceptConsumer(PipeRunner.java:221)
    at com.streamsets.datacollector.runner.PipeRunner.executeBatch(PipeRunner.java:142)
    at com.streamsets.datacollector.execution.runner.common.ProductionPipelineRunner.executeRunner(ProductionPipelineRunner.java:853)
    at com.streamsets.datacollector.execution.runner.common.ProductionPipelineRunner.runSourceLessBatch(ProductionPipelineRunner.java:831)
    at com.streamsets.datacollector.execution.runner.common.ProductionPipelineRunner.runPollSource(ProductionPipelineRunner.java:569)
    at com.streamsets.datacollector.execution.runner.common.ProductionPipelineRunner.run(ProductionPipelineRunner.java:383)
    at com.streamsets.datacollector.runner.Pipeline.run(Pipeline.java:527)
    at com.streamsets.datacollector.execution.runner.common.ProductionPipeline.run(ProductionPipeline.java:109)
    at com.streamsets.datacollector.execution.runner.common.ProductionPipelineRunnable.run(ProductionPipelineRunnable.java:75)
    at com.streamsets.datacollector.execution.runner.standalone.StandaloneRunner.start(StandaloneRunner.java:703)
    at com.streamsets.datacollector.execution.runner.common.AsyncRunner.lambda$start$3(AsyncRunner.java:151)
    at com.streamsets.pipeline.lib.executor.SafeScheduledExecutorService$SafeCallable.lambda$call$0(SafeScheduledExecutorService.java:226)
    at com.streamsets.datacollector.security.GroupsInScope.execute(GroupsInScope.java:33)
    at com.streamsets.pipeline.lib.executor.SafeScheduledExecutorService$SafeCallable.call(SafeScheduledExecutorService.java:222)
    at com.streamsets.pipeline.lib.executor.SafeScheduledExecutorService$SafeCallable.lambda$call$0(SafeScheduledExecutorService.java:226)
    at com.streamsets.datacollector.security.GroupsInScope.execute(GroupsInScope.java:33)
    at com.streamsets.pipeline.lib.executor.SafeScheduledExecutorService$SafeCallable.call(SafeScheduledExecutorService.java:222)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at com.streamsets.datacollector.metrics.MetricSafeScheduledExecutorService$MetricsTask.run(MetricSafeScheduledExecutorService.java:100)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
Caused by: javax.script.ScriptException: AttributeError: 'module' object has no attribute '_Condition' in <script> at line number 9
    at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:222)
    at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:59)
    at org.python.jsr223.PyScriptEngine.access$300(PyScriptEngine.java:20)
    at org.python.jsr223.PyScriptEngine$PyCompiledScript.eval(PyScriptEngine.java:250)
    at javax.script.CompiledScript.eval(CompiledScript.java:92)
    at com.streamsets.pipeline.stage.processor.scripting.AbstractScriptingProcessor.runScript(AbstractScriptingProcessor.java:285)
    at com.streamsets.pipeline.stage.processor.scripting.AbstractScriptingProcessor.runScript(AbstractScriptingProcessor.java:242)
    ... 34 more
Caused by: Traceback (most recent call last):
  File "<script>", line 9, in <module>
  File "/usr/local/lib/python2.7/dist-packages/boto3/__init__.py", line 100, in resource
    return _get_default_session().resource(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/boto3/session.py", line 384, in resource
    client = self.client(
  File "/usr/local/lib/python2.7/dist-packages/boto3/session.py", line 258, in client
    return self._session.create_client(
  File "/usr/local/lib/python2.7/dist-packages/botocore/session.py", line 834, in create_client
    client = client_creator.create_client(
  File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 80, in create_client
    cls = self._create_client_class(service_name, service_model)
  File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 107, in _create_client_class
    self._event_emitter.emit(
  File "/usr/local/lib/python2.7/dist-packages/botocore/hooks.py", line 356, in emit
    return self._emitter.emit(aliased_event_name, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/botocore/hooks.py", line 228, in emit
    return self._emit(event_name, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/botocore/hooks.py", line 211, in _emit
    response = handler(**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/boto3/utils.py", line 61, in _handler
    module = import_module(module)
  File "/usr/local/lib/python2.7/dist-packages/boto3/utils.py", line 52, in import_module
    __import__(name)
  File "/usr/local/lib/python2.7/dist-packages/boto3/s3/inject.py", line 15, in <module>
    from boto3.s3.transfer import create_transfer_manager
  File "/usr/local/lib/python2.7/dist-packages/boto3/s3/transfer.py", line 127, in <module>
    from s3transfer.exceptions import RetriesExceededError as \
  File "/usr/local/lib/python2.7/dist-packages/s3transfer/__init__.py", line 134, in <module>
    import concurrent.futures
  File "/usr/local/lib/python2.7/dist-packages/concurrent/futures/__init__.py", line 17, in <module>
    from concurrent.futures.thread import ThreadPoolExecutor
  File "/usr/local/lib/python2.7/dist-packages/concurrent/futures/thread.py", line 15, in <module>
    from multiprocessing import cpu_count
  File "/usr/local/lib/python2.7/dist-packages/concurrent/futures/thread.py", line 15, in <module>
    from multiprocessing import cpu_count
  File "/usr/local/lib/python2.7/dist-packages/multiprocessing/__init__.py", line 64, in <module>
    import multiprocessing.patch
  File "/usr/local/lib/python2.7/dist-packages/multiprocessing/patch.py", line 58, in <module>
    class ConditionPatch(object):
  File "/usr/local/lib/python2.7/dist-packages/multiprocessing/patch.py", line 61, in ConditionPatch
    notify_all = threading._Condition.notifyAll.im_func
AttributeError: 'module' object has no attribute '_Condition'

    at org.python.core.Py.AttributeError(Py.java:207)
    at org.python.core.PyObject.noAttributeError(PyObject.java:1032)
    at org.python.core.PyObject.__getattr__(PyObject.java:1027)
    at multiprocessing.patch$py.ConditionPatch$6(/usr/local/lib/python2.7/dist-packages/multiprocessing/patch.py:61)
    at multiprocessing.patch$py.call_function(/usr/local/lib/python2.7/dist-packages/multiprocessing/patch.py)
    at org.python.core.PyTableCode.call(PyTableCode.java:171)
    at org.python.core.PyBaseCode.call(PyBaseCode.java:308)
    at org.python.core.Py.makeClass(Py.java:2066)
    at org.python.core.Py.makeClass(Py.java:2060)
    at multiprocessing.patch$py.f$0(/usr/local/lib/python2.7/dist-packages/multiprocessing/patch.py:64)
    at multiprocessing.patch$py.call_function(/usr/local/lib/python2.7/dist-packages/multiprocessing/patch.py)
    at org.python.core.PyTableCode.call(PyTableCode.java:171)
    at org.python.core.PyCode.call(PyCode.java:18)
    at org.python.core.imp.createFromCode(imp.java:436)
    at org.python.core.imp.createFromSource(imp.java:396)
    at org.python.core.imp.loadFromSource(imp.java:667)
    at org.python.core.imp.find_module(imp.java:551)
    at org.python.core.PyModule.impAttr(PyModule.java:111)
    at org.python.core.imp.import_next(imp.java:840)
    at org.python.core.imp.import_logic(imp.java:905)
    at org.python.core.imp.import_module_level(imp.java:970)
    at org.python.core.imp.importName(imp.java:1057)
    at org.python.core.ImportFunction.__call__(__builtin__.java:1280)
    at org.python.core.PyObject.__call__(PyObject.java:450)
    at org.python.core.__builtin__.__import__(__builtin__.java:1232)
    at org.python.core.imp.importOne(imp.java:1076)
    at multiprocessing$py.f$0(/usr/local/lib/python2.7/dist-packages/multiprocessing/__init__.py:278)
    at multiprocessing$py.call_function(/usr/local/lib/python2.7/dist-packages/multiprocessing/__init__.py)
    at org.python.core.PyTableCode.call(PyTableCode.java:171)
    at org.python.core.PyCode.call(PyCode.java:18)
    at org.python.core.imp.createFromCode(imp.java:436)
    at org.python.core.imp.createFromSource(imp.java:396)
    at org.python.core.imp.loadFromSource(imp.java:667)
    at org.python.core.imp.find_module(imp.java:551)
    at org.python.core.imp.import_next(imp.java:838)
    at org.python.core.imp.import_first(imp.java:872)
    at org.python.core.imp.import_module_level(imp.java:964)
    at org.python.core.imp.importName(imp.java:1057)
    at org.python.core.ImportFunction.__call__(__builtin__.java:1280)
    at org.python.core.PyObject.__call__(PyObject.java:450)
    at org.python.core.__builtin__.__import__(__builtin__.java:1232)
    at org.python.core.imp.importFromAs(imp.java:1149)
 ... Truncated ...
 ... Truncated ...

0 个答案:

没有答案