2

I have been struggling with this problem for a while now and have scoured the internet but am still unable to solve it.

I am trying to run a python script to access a google sheet from my local machine at work (so may be firewall issues). Whenever I am connected on a guest network the script works fine. Whenever I try to use my work internal network (with or without proxy settings) I get the following error:

***Traceback (most recent call last):
  File "C:\Python36-32\lib\site-packages\httplib2\__init__.py", line 995, in _conn_request
    conn.connect()
  File "C:\Python36-32\lib\http\client.py", line 1392, in connect
    super().connect()
  File "C:\Python36-32\lib\http\client.py", line 936, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "C:\Python36-32\lib\socket.py", line 704, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "C:\Python36-32\lib\socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11004] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.1\helpers\pydev\pydevd.py", line 1664, in <module>
    main()
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.1\helpers\pydev\pydevd.py", line 1658, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.1\helpers\pydev\pydevd.py", line 1068, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.1\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/Git/datalab-notebooks/2017-vin-profitability/US/Finance_Mapping_test.py", line 23, in <module>
    client = gspread.authorize(credentials)
  File "C:\Python36-32\lib\site-packages\gspread\__init__.py", line 38, in authorize
    client.login()
  File "C:\Python36-32\lib\site-packages\gspread\client.py", line 52, in login
    self.auth.refresh(http)
  File "C:\Python36-32\lib\site-packages\oauth2client\client.py", line 668, in refresh
    self._refresh(http.request)
  File "C:\Python36-32\lib\site-packages\oauth2client\client.py", line 873, in _refresh
    self._do_refresh_request(http_request)
  File "C:\Python36-32\lib\site-packages\oauth2client\client.py", line 905, in _do_refresh_request
    self.token_uri, method='POST', body=body, headers=headers)
  File "C:\Python36-32\lib\site-packages\httplib2\__init__.py", line 1322, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "C:\Python36-32\lib\site-packages\httplib2\__init__.py", line 1072, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "C:\Python36-32\lib\site-packages\httplib2\__init__.py", line 1002, in _conn_request
    raise ServerNotFoundError("Unable to find the server at %s" % conn.host)
httplib2.ServerNotFoundError: Unable to find the server at accounts.google.com***

After some research I get the impression that it is due to my proxy settings but I cant figure out what I need to do to fix it. I also understand that the python library socks may help but once again I'm stumped

Any help would be much appreciated

Thanks in advance

Jacob
  • 91
  • 1
  • 2
  • 4

1 Answers1

0

While this was asked a long time ago, I wanted to share the fix that worked for me.

The error occurred when I used the host with the protocol

httplib2.ProxyInfo(
    proxy_type=httplib2.socks.PROXY_TYPE_HTTP,
    proxy_host='https://proxy.prod.com',
)

Removing the protocol solved the problem:

httplib2.ProxyInfo(
    proxy_type=httplib2.socks.PROXY_TYPE_HTTP,
    proxy_host='proxy.prod.com',
)
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
mlueckl
  • 198
  • 11