Unexpected keyword argument 'ssl_context'`
See original GitHub issueI have this context:
Distributor ID: Ubuntu Description: Ubuntu 16.04.6 LTS Release: 16.04 Codename: xenial python3 --version Python 3.7.7 python --version Python 2.7.12 aws --version aws-cli/2.0.6 Python/3.7.3 Linux/4.4.0-1101-aws botocore/2.0.0dev10
I have this return error
ubuntu@ip-############:~$ python3 mixer_s3.py Traceback (most recent call last): File “/home/ubuntu/.local/lib/python3.7/site-packages/botocore/httpsession.py”, line 263, in send chunked=self._chunked(request.headers), File “/usr/lib/python3/dist-packages/urllib3/connectionpool.py”, line 549, in urlopen conn = self._get_conn(timeout=pool_timeout) File “/usr/lib/python3/dist-packages/urllib3/connectionpool.py”, line 251, in _get_conn return conn or self._new_conn() File “/usr/lib/python3/dist-packages/urllib3/connectionpool.py”, line 212, in _new_conn strict=self.strict, **self.conn_kw) File “/usr/lib/python3/dist-packages/urllib3/connection.py”, line 121, in init _HTTPConnection.init(self, *args, **kw) TypeError: init() got an unexpected keyword argument ‘ssl_context’
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “mixer_s3.py”, line 31, in <module> s3_client = boto3.client(‘s3’, verify=False) File “/home/ubuntu/.local/lib/python3.7/site-packages/boto3/init.py”, line 91, in client return _get_default_session().client(*args, **kwargs) File “/home/ubuntu/.local/lib/python3.7/site-packages/boto3/session.py”, line 263, in client aws_session_token=aws_session_token, config=config) File “/home/ubuntu/.local/lib/python3.7/site-packages/botocore/session.py”, line 823, in create_client credentials = self.get_credentials() File “/home/ubuntu/.local/lib/python3.7/site-packages/botocore/session.py”, line 428, in get_credentials ‘credential_provider’).load_credentials() File “/home/ubuntu/.local/lib/python3.7/site-packages/botocore/credentials.py”, line 1948, in load_credentials creds = provider.load() File “/home/ubuntu/.local/lib/python3.7/site-packages/botocore/credentials.py”, line 1001, in load metadata = fetcher.retrieve_iam_role_credentials() File “/home/ubuntu/.local/lib/python3.7/site-packages/botocore/utils.py”, line 397, in retrieve_iam_role_credentials token = self._fetch_metadata_token() File “/home/ubuntu/.local/lib/python3.7/site-packages/botocore/utils.py”, line 296, in _fetch_metadata_token response = self._session.send(request.prepare()) File “/home/ubuntu/.local/lib/python3.7/site-packages/botocore/httpsession.py”, line 299, in send raise HTTPClientError(error=e) botocore.exceptions.HTTPClientError: An HTTP Client raised and unhandled exception: init() got an unexpected keyword argument ‘ssl_context’
With long code, but only two boto3 calls:
import boto3 s3_client = boto3.client('s3') s3 = boto3.resource('s3') my_bucket = s3.Bucket("@@@@@@@@@@") s3_client.download_file(bucket, key, download_path) s3_client.upload_file( "/home/ubu/mixed/mixed.mp3", "source-audio-mixer", "mixed/{}/mixed.mp3".format(dt_string), ExtraArgs={'ACL': 'public-read'})
All was working before I have python3.5 then upgraded to python.3.7 and reinstalled all packages and dependencies.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (2 by maintainers)
Top GitHub Comments
I’m glad that resolved the issue, @bacloud14! So the underlying issue is we’re calling urllib3 with keyword arguments assuming it’s at least version 1.20 or higher which will support the SSL context. Looking at the stacktrace again, your Python runtime is pulling packages from two different locations (your local install:
/home/ubuntu/.local/lib/python3.7/site-packages/
and the system default python 3:/usr/lib/python3/dist-packages/
) which won’t be managed by the same pip installation.You’ll notice the urllib3 install you were using is being pulled from the system Python3 while the rest of the packages are from Python3.7. When you reinstalled it either corrected the path so one location is used, or resolved the underlying interpreter issue that was causing your
Python3
interpreter to grab the Ubuntu installed urllib3.This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don’t have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.