首页 > 解决方案 > 如何将代理添加到 quickstart.py-python

问题描述

我按照教程的步骤执行quickstart.py,他会报错。我很确定它与我所在的代理有关,所以我特别想知道如何将我的代理添加到 quickstart.py 以及如何添加它是正确的。报错信息如下,望解答,谢谢!

Traceback (most recent call last):
  File "D:\Python\lib\site-packages\urllib3\connectionpool.py", line 696, in urlopen
    self._prepare_proxy(conn)
  File "D:\Python\lib\site-packages\urllib3\connectionpool.py", line 964, in _prepare_proxy
    conn.connect()
  File "D:\Python\lib\site-packages\urllib3\connection.py", line 359, in connect
    conn = self._connect_tls_proxy(hostname, conn)
  File "D:\Python\lib\site-packages\urllib3\connection.py", line 506, in _connect_tls_proxy
    ssl_context=ssl_context,
  File "D:\Python\lib\site-packages\urllib3\util\ssl_.py", line 450, in ssl_wrap_socket
    sock, context, tls_in_tls, server_hostname=server_hostname
  File "D:\Python\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "D:\Python\lib\ssl.py", line 423, in wrap_socket
    session=session
  File "D:\Python\lib\ssl.py", line 870, in _create
    self.do_handshake()
  File "D:\Python\lib\ssl.py", line 1139, in do_handshake
    self._sslobj.do_handshake()
OSError: [Errno 0] Error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Python\lib\site-packages\requests\adapters.py", line 449, in send
    timeout=timeout
  File "D:\Python\lib\site-packages\urllib3\connectionpool.py", line 756, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "D:\Python\lib\site-packages\urllib3\util\retry.py", line 574, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='oauth2.googleapis.com', port=443): Max retries exceeded with url: /token (Caused by ProxyError('Cannot connect to proxy.', OSError(0, 'Error')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:/2021-0/Project/eliis_arno/RpaChangeOrder/test/quickstart.py", line 47, in <module>
    main()
  File "D:/2021-0/Project/eliis_arno/RpaChangeOrder/test/quickstart.py", line 28, in main
    creds = flow.run_local_server(port=0)
  File "D:\Python\lib\site-packages\google_auth_oauthlib\flow.py", line 479, in run_local_server
    self.fetch_token(authorization_response=authorization_response)
  File "D:\Python\lib\site-packages\google_auth_oauthlib\flow.py", line 288, in fetch_token
    return self.oauth2session.fetch_token(self.client_config["token_uri"], **kwargs)
  File "D:\Python\lib\site-packages\requests_oauthlib\oauth2_session.py", line 344, in fetch_token
    **request_kwargs
  File "D:\Python\lib\site-packages\requests_oauthlib\oauth2_session.py", line 516, in request
    method, url, headers=headers, data=data, **kwargs
  File "D:\Python\lib\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "D:\Python\lib\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "D:\Python\lib\site-packages\requests\adapters.py", line 510, in send
    raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='oauth2.googleapis.com', port=443): Max retries exceeded with url: /token (Caused by ProxyError('Cannot connect to proxy.', OSError(0, 'Error')))

标签: pythongmail-api

解决方案


推荐阅读