I have an issue when initializing s3 client with python3.6 and boto3-1.5.6.
Here is an example code.
import boto3
client = boto3.client('s3')
I got the following error.
Traceback (most recent call last):
File "/home/ec2-user/environment/debug/sample.py", line 2, in <module>
client = boto3.client('s3')
File "/home/ec2-user/environment/debug/boto3/__init__.py", line 83, in client
return _get_default_session().client(*args, **kwargs)
File "/home/ec2-user/environment/debug/boto3/session.py", line 263, in client
aws_session_token=aws_session_token, config=config)
File "/home/ec2-user/environment/debug/botocore/session.py", line 861, in create_client
client_config=config, api_version=api_version)
File "/home/ec2-user/environment/debug/botocore/client.py", line 70, in create_client
cls = self._create_client_class(service_name, service_model)
File "/home/ec2-user/environment/debug/botocore/client.py", line 95, in _create_client_class
base_classes=bases)
File "/home/ec2-user/environment/debug/botocore/hooks.py", line 227, in emit
return self._emit(event_name, kwargs)
File "/home/ec2-user/environment/debug/botocore/hooks.py", line 210, in _emit
response = handler(**kwargs)
File "/home/ec2-user/environment/debug/boto3/utils.py", line 61, in _handler
module = import_module(module)
File "/home/ec2-user/environment/debug/boto3/utils.py", line 52, in import_module
__import__(name)
File "/home/ec2-user/environment/debug/boto3/s3/inject.py", line 15, in <module>
from boto3.s3.transfer import create_transfer_manager
File "/home/ec2-user/environment/debug/boto3/s3/transfer.py", line 127, in <module>
from s3transfer.exceptions import RetriesExceededError as \
File "/home/ec2-user/environment/debug/s3transfer/__init__.py", line 134, in <module>
import concurrent.futures
File "/home/ec2-user/environment/debug/concurrent/futures/__init__.py", line 8, in <module>
from concurrent.futures._base import (FIRST_COMPLETED,
File "/home/ec2-user/environment/debug/concurrent/futures/_base.py", line 414
raise exception_type, self._exception, self._traceback
^
SyntaxError: invalid syntax
Testing environment is by using AWS Cloud9, however the same error is reproduced in another environment with python3.6 and newest boto3.
In the case of creating DynamoDB client, there is no error.
How can I fix it ?
Looks like you might have the backport of futures installed, I would recommend uninstalling it.
Closing due to inactivity.
@JordonPhillips Thank you!! You saved me many hours. I ran into this issue when deploying to AWS Lambda. pip3 uninstall futures did the trick.
an issue for me and Cannot uninstall requirement futures, not installed
I also have this issue. I am using aws-sam-cli and following the readme to install requirements. In this case my requirements.txt file only contains boto3 and I run pip install -r requirements.txt -t hello_world/build/. Getting syntax error in _base.py of boto3.
Here is the error message:
"errorMessage": "invalid syntax (_base.py, line 414)", "errorType": "SyntaxError", "stackTrace": [["/var/task/app.py", 13, "lambda_handler", "s3 = boto3.resource(\"s3\")"], ["/var/task/boto3/__init__.py", 100, "resource", "return _get_default_session().resource(*args, **kwargs)"], ["/var/task/boto3/session.py", 389, "resource", "aws_session_token=aws_session_token, config=config)"], ["/var/task/boto3/session.py", 263, "client", "aws_session_token=aws_session_token, config=config)"], ["/var/task/botocore/session.py", 889, "create_client", "client_config=config, api_version=api_version)"], ["/var/task/botocore/client.py", 70, "create_client", "cls = self._create_client_class(service_name, service_model)"], ["/var/task/botocore/client.py", 97, "_create_client_class", "base_classes=bases)"], ["/var/task/botocore/hooks.py", 356, "emit", "return self._emitter.emit(aliased_event_name, **kwargs)"], ["/var/task/botocore/hooks.py", 228, "emit", "return self._emit(event_name, kwargs)"], ["/var/task/botocore/hooks.py", 211, "_emit", "response = handler(**kwargs)"], ["/var/task/boto3/utils.py", 61, "_handler", "module = import_module(module)"], ["/var/task/boto3/utils.py", 52, "import_module", "__import__(name)"], ["/var/task/boto3/s3/inject.py", 15, "<module>", "from boto3.s3.transfer import create_transfer_manager"], ["/var/task/boto3/s3/transfer.py", 127, "<module>", "from s3transfer.exceptions import RetriesExceededError as \\"], ["/var/task/s3transfer/__init__.py", 134, "<module>", "import concurrent.futures"], ["/var/task/concurrent/futures/__init__.py", 8, "<module>", "from concurrent.futures._base import (FIRST_COMPLETED,"]]}
So I solved this issue when running local invoke by going into the build folder of function and deleting futures as well as concurrent. This will have to be done after everypip install though.
Seems the issue is a pinned futures or concurrent package in boto or one of its dependent packages.
Why is this closed?
I just had this problem, the only extra package installed is requests
In case it helps others coming to this same thread -- I also ran into this when installing smart-open. The solution that worked for me was to go back to Python 2.7 -- I had this error with both Python 3.6 and 3.7
The fix for this is to change either
concurrent/futures/I faced this exact issue and was routed from - https://forums.aws.amazon.com/thread.jspa?messageID=935868󤞼
In my case I was not having concurrent/futures/ package but I had both requests and urllib3 packages.
The issue fixed when I just increased the Memory limit for Greengrass Lambda.
Most helpful comment
Why is this closed?
I just had this problem, the only extra package installed is
requests