When I try to use boto3 session like this
import boto3
session = boto3.Session(profile_name='my-profile')
I am getting the following error
Traceback (most recent call last):
File "/users/myuser/test.py", line 1, in <module>
import boto3
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/boto3/__init__.py", line 16, in <module>
from boto3.session import Session
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/boto3/session.py", line 17, in <module>
import botocore.session
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/botocore/session.py", line 29, in <module>
import botocore.configloader
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/botocore/configloader.py", line 19, in <module>
from botocore.compat import six
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/botocore/compat.py", line 25, in <module>
from botocore.exceptions import MD5UnavailableError
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/botocore/exceptions.py", line 15, in <module>
from botocore.vendored import requests
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/botocore/vendored/requests/__init__.py", line 53, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/botocore/vendored/requests/packages/__init__.py", line 3, in <module>
from . import urllib3
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/botocore/vendored/requests/packages/urllib3/__init__.py", line 10, in <module>
from .connectionpool import (
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 31, in <module>
from .connection import (
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/botocore/vendored/requests/packages/urllib3/connection.py", line 9, in <module>
from http.client import HTTPConnection as _HTTPConnection, HTTPException
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 71, in <module>
import email.parser
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/email/parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/email/feedparser.py", line 27, in <module>
from email._policybase import compat32
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/email/_policybase.py", line 9, in <module>
from email.utils import _has_surrogates
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/email/utils.py", line 28, in <module>
import test
File "/Users/myuser/random.py", line 3, in <module>
session = boto3.Session(profile_name='my-profile')
AttributeError: module 'boto3' has no attribute 'Session'
Seems like I can't do anything with boto3 anymore. Tried re-installing botocore and boto3.
The problem was that I had a file named random.py and it apparently conflicts with something.
Most helpful comment
The problem was that I had a file named random.py and it apparently conflicts with something.