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.

Unexpected keyword argument 'ssl_context'`

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nateprewittcommented, Mar 31, 2020

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.

0reactions
no-response[bot]commented, Apr 8, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python TLS client code gives Wrap Socket unexpected ...
The reason for the unexpected keyword error is because SSLContext.wrap_socket does not have a ca_cert parameter as you can see in the ...
Read more >
self-signed ssl: wrap_socket: __init__() got an unexpected ...
I am attempting to run a tornado https server with self signed certificates (with localhost as the domain name) I generated using openssl....
Read more >
1384491 – TypeError: __init__() got an unexpected ...
Description of problem: When running our 22 LC on RHEL7.2 (updated) that connects to our beaker server over SSL, following error appears when...
Read more >
I'm facing SSL (?) problems when I GET files to my local file ...
TypeError: getresponse() got an unexpected keyword argument 'buffering'. During handling of the above exception, another exception occurred:.
Read more >
Bug #1834565 “python 3.7: wrap_socket() got an unexpected ...
SOCK_STREAM) wrappedSocket = ssl.wrap_socket(sock) EOF Traceback ... TypeError: wrap_socket() got an unexpected keyword argument '_context'.
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