4
  • python==3.8.2
  • google-api-python-client==1.6.5 1.9.3

Hello,

I'm having a SSL error when using google-api-python-client. Calling to sample_tools.init() for getting a service object triggers an error. This was working before I reinstalled Kubuntu and updated to python 3.8 (coming from 3.6.10).

I have googled but I can't find this exact error. I tried updating the version of the library, but didn't work and went back to the old one. Any piece of help, documentation or resource will be welcome, given that I have no clue what to try.

I have also tried used pyenv for making an additional alternative python install for 3.8.2 with python3-openssl and libssl-dev installed as described here and then a virtualenv inside PyCharm with that python. No luck.

This is the traceback:

Traceback (most recent call last):
  File "/home/madtyn/PycharmProjects/alfredBot/my_bot.py", line 427, in main
    reload_credentials()
  File "/home/madtyn/PycharmProjects/alfredBot/apis/blogger/blogger_insert.py", line 84, in reload_credentials
    service, flags = sample_tools.init(
  File "/home/madtyn/venvs/alfred38/lib/python3.8/site-packages/googleapiclient/sample_tools.py", line 90, in init
    credentials = tools.run_flow(flow, storage, flags)
  File "/home/madtyn/venvs/alfred38/lib/python3.8/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/madtyn/venvs/alfred38/lib/python3.8/site-packages/oauth2client/tools.py", line 243, in run_flow
    credential = flow.step2_exchange(code, http=http)
  File "/home/madtyn/venvs/alfred38/lib/python3.8/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/madtyn/venvs/alfred38/lib/python3.8/site-packages/oauth2client/client.py", line 2053, in step2_exchange
    resp, content = transport.request(
  File "/home/madtyn/venvs/alfred38/lib/python3.8/site-packages/oauth2client/transport.py", line 280, in request
    return http_callable(uri, method=method, body=body, headers=headers,
  File "/home/madtyn/venvs/alfred38/lib/python3.8/site-packages/httplib2/__init__.py", line 1322, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "/home/madtyn/venvs/alfred38/lib/python3.8/site-packages/httplib2/__init__.py", line 1072, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/home/madtyn/venvs/alfred38/lib/python3.8/site-packages/httplib2/__init__.py", line 995, in _conn_request
    conn.connect()
  File "/usr/lib/python3.8/http/client.py", line 1409, in connect
    self.sock = self._context.wrap_socket(self.sock,
  File "/usr/lib/python3.8/ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/lib/python3.8/ssl.py", line 1040, in _create
    self.do_handshake()
  File "/usr/lib/python3.8/ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL] internal error (_ssl.c:1108)
madtyn
  • 1,469
  • 27
  • 55
  • 1
    How did you install Python 3.8? depending on that, check that your O.S. have OpenSSL installed and reinstall/recompile Python 3.8 again – c0x6a Jun 05 '20 at 23:25
  • Well, I just had all my development in my /home partition under my user directory, so Python went brand-new at version 3.8 when I reinstalled Linux. I just made a virtualenv. I tried `sudo apt install openssl` and it was already installed – madtyn Jun 05 '20 at 23:44
  • 2
    try using `pyenv` to manage your Python versions instead of relying on the Python from the O.S., make sure you have all neccesary OpenSSL dev packages so when `pyenv` installs/compiles Python, it will have SSL support. – c0x6a Jun 06 '20 at 16:47
  • Hello, @c0x6a. Never used pyenv. What should I do? Uninstall python completely, install openssl-dev and reinstall? Do it only from the virtualenv? – madtyn Jun 06 '20 at 17:55
  • 1
    just install it and use it for your Python projects, leave the Python from the O.S. alone, don't touch it unless for very necessary things, if you uninstall it you will break your O.S., using `pyenv` let's you use a different Python versions apart from the one shipped by your O.S. – c0x6a Jun 11 '20 at 22:06
  • I installed pyenv following instructions from a realpython tutorial. After doing everything, I created a virtualenv inside PyCharm and ran the project. Same error. I verified I was using the new Python from pyenv. :-( – madtyn Jun 13 '20 at 13:45
  • 1
    Strange, I was curious about it and I created a virtual environment using my `pyenv` installation, then installed `google-api-python-client` and tried this example: https://github.com/googleapis/google-api-python-client/blob/master/docs/logging.md (fix the `print` code for Python3) and it works without any problems. Verify that you have all the needed dev versions of `openssl` installed in your O.S. and try installing a new Python version using `pyenv` – c0x6a Jun 14 '20 at 02:58
  • As you can read at https://realpython.com/intro-to-pyenv/ I installed python-openssl and libssl-dev. I don't know which other libraries are required for ssl. I'm re-trying as soon as I can – madtyn Jun 14 '20 at 06:38
  • Tried that. Same error. =:-( – madtyn Jun 14 '20 at 07:31

1 Answers1

2

Seems, the same issue exists in Google calendar too. There's a open bug submitted in the Google calendar github repo . It may take sometime to resolve this issue.

Ref: https://github.com/home-assistant/core/issues/35870

For now, You can install multiple python versions in the same machine. If you install them through, compile from source method. At the time of installation use make altinstall. This way you can point the previously working python version into you application and complete it. Once it resolved you can switch back to the newer version.

Giri Annamalai M
  • 810
  • 9
  • 24