question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportError: cannot import name ReadTimeoutError when trying to create s3 client

See original GitHub issue

trying to create a boto3 s3 client on EMR Master node.

  • boto3 version: 1.9.90
  • requests version 1.2.3
  • python 2.7.14

just running this in the python interpreter: s3 = boto3.client('s3')

I get this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/boto3/__init__.py", line 91, in client
    return _get_default_session().client(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/boto3/session.py", line 263, in client
    aws_session_token=aws_session_token, config=config)
  File "/usr/lib/python2.7/dist-packages/botocore/session.py", line 861, in create_client
    client_config=config, api_version=api_version)
  File "/usr/lib/python2.7/dist-packages/botocore/client.py", line 70, in create_client
    cls = self._create_client_class(service_name, service_model)
  File "/usr/lib/python2.7/dist-packages/botocore/client.py", line 95, in _create_client_class
    base_classes=bases)
  File "/usr/lib/python2.7/dist-packages/botocore/hooks.py", line 227, in emit
    return self._emit(event_name, kwargs)
  File "/usr/lib/python2.7/dist-packages/botocore/hooks.py", line 210, in _emit
    response = handler(**kwargs)
  File "/usr/local/lib/python2.7/site-packages/boto3/utils.py", line 61, in _handler
    module = import_module(module)
  File "/usr/local/lib/python2.7/site-packages/boto3/utils.py", line 52, in import_module
    __import__(name)
  File "/usr/local/lib/python2.7/site-packages/boto3/s3/inject.py", line 15, in <module>
    from boto3.s3.transfer import create_transfer_manager
  File "/usr/local/lib/python2.7/site-packages/boto3/s3/transfer.py", line 129, in <module>
    from s3transfer.manager import TransferConfig as S3TransferConfig
  File "/usr/local/lib/python2.7/site-packages/s3transfer/manager.py", line 21, in <module>
    from s3transfer.utils import get_callbacks
  File "/usr/local/lib/python2.7/site-packages/s3transfer/utils.py", line 27, in <module>
    from botocore.exceptions import ReadTimeoutError
ImportError: cannot import name ReadTimeoutError

This appears to be a package structure problem to me

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:19 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
sqNutriencommented, Feb 11, 2019

honestly, I don’t know what version of botocore I had… I ended up specifying the following versions and everything worked nicely for me after that: botocore==1.12.91 urllib3==1.24.1 boto3==1.9.91

1reaction
czechnologycommented, Feb 12, 2019

Update: It turns out the problem was a mismatch between the provided boto libraries in AWS Lambda and the libraries I packaged into my Lambda code.

boto3: 1.7.74 
botocore: 1.10.74 
s3transfer: 0.2.0 
urllib3: 1.24.1

cannot import name 'ReadTimeoutError': ImportError
Traceback (most recent call last):
File "/var/task/awstools/core.py", line 59, in __init__
s3 = boto3.client('s3')
File "/var/runtime/boto3/session.py", line 263, in client
aws_session_token=aws_session_token, config=config)
File "/var/runtime/botocore/session.py", line 885, in create_client
client_config=config, api_version=api_version)
File "/var/runtime/botocore/client.py", line 70, in create_client
cls = self._create_client_class(service_name, service_model)
File "/var/runtime/botocore/client.py", line 95, in _create_client_class
base_classes=bases)
File "/var/runtime/botocore/hooks.py", line 227, in emit
return self._emit(event_name, kwargs)
File "/var/runtime/botocore/hooks.py", line 210, in _emit
response = handler(**kwargs)
File "/var/runtime/boto3/utils.py", line 61, in _handler
module = import_module(module)
File "/var/runtime/boto3/utils.py", line 52, in import_module
__import__(name)
File "/var/runtime/boto3/s3/inject.py", line 15, in <module>
from boto3.s3.transfer import create_transfer_manager
File "/var/runtime/boto3/s3/transfer.py", line 129, in <module>
from s3transfer.manager import TransferConfig as S3TransferConfig
File "/var/task/s3transfer/manager.py", line 21, in <module>
from s3transfer.utils import get_callbacks
File "/var/task/s3transfer/utils.py", line 27, in <module>
from botocore.exceptions import ReadTimeoutError
ImportError: cannot import name 'ReadTimeoutError'

Fixed once I improved my packaging approach. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python import boto3 error: cannot import name ClientError
The program cannot correctly import boto3. When it tries to import boto3 for the first time, Python gives error ImportError: cannot import name...
Read more >
Error handling — Boto3 Docs 1.18.48 documentation - AWS
import botocore import boto3 client = boto3.client('aws_service_name') try: client.some_api_call(SomeParam='some_param') except botocore.exceptions.
Read more >
Unable to run AWS CLI: "ImportError: cannot import name ...
New to linux, I just installed AWS CLI alongside Python3 and boto3 but I get this error when I tried running AWS CLI....
Read more >
Creating and using Amazon S3 buckets - AWS Documentation
Create a libs directory, and create a Node.js module with the file name s3Client.js . Copy and paste the code below into it,...
Read more >
3 ways to test S3 in Python - Sanjay Siddhanti
from dataclasses import dataclass import json import boto3 S3_BUCKET = "recipes" def get_s3(): return boto3.client("s3") @dataclass class ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found