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.

import boto3 error

See original GitHub issue

Import boto3 always gives error. When I tries to import boto3 for the first time, Python gives error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/boto3/__init__.py", line 16, in <module>
    from boto3.session import Session
  File "/usr/local/lib/python2.7/site-packages/boto3/session.py", line 17, in <module>
    import botocore.session
  File "/usr/local/lib/python2.7/site-packages/botocore/session.py", line 25, in <module>
    import botocore.configloader
  File "/usr/local/lib/python2.7/site-packages/botocore/configloader.py", line 19, in <module>
    from botocore.compat import six
  File "/usr/local/lib/python2.7/site-packages/botocore/compat.py", line 25, in <module>
    from botocore.exceptions import MD5UnavailableError
  File "/usr/local/lib/python2.7/site-packages/botocore/exceptions.py", line 15, in <module>
    from botocore.vendored.requests.exceptions import ConnectionError
  File "/usr/local/lib/python2.7/site-packages/botocore/vendored/requests/__init__.py", line 58, in <module>
    from . import utils
  File "/usr/local/lib/python2.7/site-packages/botocore/vendored/requests/utils.py", line 26, in <module>
    from .compat import parse_http_list as _parse_list_header
  File "/usr/local/lib/python2.7/site-packages/botocore/vendored/requests/compat.py", line 7, in <module>
    from .packages import chardet
  File "/usr/local/lib/python2.7/site-packages/botocore/vendored/requests/packages/__init__.py", line 3, in <module>
    from . import urllib3
  File "/usr/local/lib/python2.7/site-packages/botocore/vendored/requests/packages/urllib3/__init__.py", line 10, in <module>
    from .connectionpool import (
  File "/usr/local/lib/python2.7/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 37, in <module>
    from .request import RequestMethods
  File "/usr/local/lib/python2.7/site-packages/botocore/vendored/requests/packages/urllib3/request.py", line 6, in <module>
    from .filepost import encode_multipart_formdata
  File "/usr/local/lib/python2.7/site-packages/botocore/vendored/requests/packages/urllib3/filepost.py", line 8, in <module>
    from .fields import RequestField
  File "/usr/local/lib/python2.7/site-packages/botocore/vendored/requests/packages/urllib3/fields.py", line 1, in <module>
    import email.utils
  File "email.py", line 2, in <module>
    from botocore.exceptions import ClientError
ImportError: cannot import name ClientError

If I try to import again, the error becomes

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/boto3/__init__.py", line 16, in <module>
    from boto3.session import Session
  File "/usr/local/lib/python2.7/site-packages/boto3/session.py", line 17, in <module>
    import botocore.session
  File "/usr/local/lib/python2.7/site-packages/botocore/session.py", line 25, in <module>
    import botocore.configloader
  File "/usr/local/lib/python2.7/site-packages/botocore/configloader.py", line 19, in <module>
    from botocore.compat import six
  File "/usr/local/lib/python2.7/site-packages/botocore/compat.py", line 25, in <module>
    from botocore.exceptions import MD5UnavailableError
  File "/usr/local/lib/python2.7/site-packages/botocore/exceptions.py", line 15, in <module>
    from botocore.vendored.requests.exceptions import ConnectionError
  File "/usr/local/lib/python2.7/site-packages/botocore/vendored/requests/__init__.py", line 58, in <module>
    from . import utils
  File "/usr/local/lib/python2.7/site-packages/botocore/vendored/requests/utils.py", line 25, in <module>
    from . import certs
ImportError: cannot import name certs

I have tried to use old version

boto3==1.4.4
botocore==1.5.95

And I also tried to upgrade to latest version

boto3==1.5.6
botocore==1.8.20

both of these give the same error.

AWS version that I use is

awscli==1.14.16
awsebcli==3.12.1

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
jiashenCcommented, Jan 10, 2018

Please look at this post

I think our mistake is to put our file named as email.py and Python cannot pick up the correct module as pointed by the post.

It is not related to package installation. Just rename the file.

0reactions
stealthycoincommented, Jan 18, 2018

Looks like @jiashenC figured it out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python import boto3 error: cannot import name ClientError
When it tries to import boto3 for the first time, Python gives error ImportError: cannot import name ClientError . If I try to...
Read more >
Error handling — Boto3 Docs 1.26.32 documentation - AWS
Boto3 classifies all AWS service errors and exceptions as ClientError exceptions. When attempting to catch AWS service exceptions, one way is to catch ......
Read more >
How to solve the No module named boto3 error in Python?
Fix the no module found boto3 error · Save any previously opened Python programs. · Close your IDE. · Open your Terminal window...
Read more >
[Fixed] ModuleNotFoundError: No module named 'boto3'
Solution Idea 1: Install Library boto3 ... The most likely reason is that Python doesn't provide boto3 in its standard library. You need...
Read more >
Import boto3 importerror no module named boto3 : Crack it
We can fix the error import boto3 importerror no module named boto3 using just installing boto3 python package in your system. boto3 is...
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