Acumos model onboarding python CLI - python

I'm trying to onboard a simple python model from CLI as shown in the related tutorial.
After providing the onboarding token (user:api-token) I'm getting the error below.
The Acumos platform has been deployed using the AIO tools using prep-deploy process.
I was able to dump the same model and onboard using the web UI.
Traceback (most recent call last):
File "/home/gprato/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 677, in urlopen
chunked=chunked,
File "/home/gprato/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 381, in _make_request
self._validate_conn(conn)
File "/home/gprato/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 978, in _validate_conn
conn.connect()
File "/home/gprato/.local/lib/python3.6/site-packages/urllib3/connection.py", line 371, in connect
ssl_context=context,
File "/home/gprato/.local/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 384, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/lib/python3.6/ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "/usr/lib/python3.6/ssl.py", line 817, in __init__
self.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 1077, in do_handshake
self._sslobj.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/gprato/.local/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/home/gprato/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 727, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "/home/gprato/.local/lib/python3.6/site-packages/urllib3/util/retry.py", line 439, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='***', port=443): Max retries exceeded with url: /onboarding-app/v2/models (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "simple_example.py", line 16, in <module>
session.push(model, 'example-2')
File "/home/gprato/.local/lib/python3.6/site-packages/acumos/session.py", line 103, in push
_push_model(dump_dir, self.push_api, self.auth_api, options, extra_headers=extra_headers)
File "/home/gprato/.local/lib/python3.6/site-packages/acumos/session.py", line 172, in _push_model
_post_model(files, push_api, auth_api, tries, max_tries, extra_headers, options)
File "/home/gprato/.local/lib/python3.6/site-packages/acumos/session.py", line 192, in _post_model
resp = requests.post(push_api, files=files, headers=headers)
File "/home/gprato/.local/lib/python3.6/site-packages/requests/api.py", line 119, in post
return request('post', url, data=data, json=json, **kwargs)
File "/home/gprato/.local/lib/python3.6/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/home/gprato/.local/lib/python3.6/site-packages/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/home/gprato/.local/lib/python3.6/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/home/gprato/.local/lib/python3.6/site-packages/requests/adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='***', port=443): Max retries exceeded with url: /onboarding-app/v2/models (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),))
UPDATE
I've solved by adding the following line into the python script:
os.environ['CURL_CA_BUNDLE'] = ""
In addition to that I also had to change the push url ("acumos/onboarding-app/v2/models") as it was wrongly reported in the acumos python client library ("acumos/onboarding-app/v2/push").

I recomend you to add the following in your python script
os.environ['CURL_CA_BUNDLE'] = ""
it will skip the certificate verification

Related

How can you disable SSL verification in urlib3?

I am getting this error:
Traceback (most recent call last):
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/urllib3/connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
conn.connect()
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/urllib3/connection.py", line 416, in connect
self.sock = ssl_wrap_socket(
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/urllib3/util/ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
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: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1131)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/requests/adapters.py", line 489, in send
resp = conn.urlopen(
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/urllib3/connectionpool.py", line 787, in urlopen
retries = retries.increment(
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.example.com', port=8080): Max retries exceeded with url: /geoserver/ows?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=qazqoinau_test%3A%D0%93%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0%20%D0%A0%D0%B5%D1%81%D0%BF%D1%83%D0%B1%D0%BB%D0%B8%D0%BA%D0%B8%20%D0%9A%D0%B0%D0%B7%D0%B0%D1%85%D1%81%D1%82%D0%B0%D0%BD&STYLES=qazqoinau_test%3Alayers_border_RK&SRS=EPSG%3A3857&CRS=EPSG%3A3857&TILED=true&access_token=JNkYj4bIfuWQbQu06AAF2MUxc9banx&WIDTH=512&HEIGHT=512&BBOX=2504688.542848654%2C2504688.542848654%2C5009377.08569731%2C5009377.08569731 (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1131)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/requests/api.py", line 73, in get
return request("get", url, params=params, **kwargs)
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url,verify=False,**kwargs)
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/requests/sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/requests/sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/requests/adapters.py", line 563, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='www.example.com', port=8080): Max retries exceeded with url: /geoserver/ows?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=qazqoinau_test%3A%D0%93%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0%20%D0%A0%D0%B5%D1%81%D0%BF%D1%83%D0%B1%D0%BB%D0%B8%D0%BA%D0%B8%20%D0%9A%D0%B0%D0%B7%D0%B0%D1%85%D1%81%D1%82%D0%B0%D0%BD&STYLES=qazqoinau_test%3Alayers_border_RK&SRS=EPSG%3A3857&CRS=EPSG%3A3857&TILED=true&access_token=JNkYj4bIfuWQbQu06AAF2MUxc9banx&WIDTH=512&HEIGHT=512&BBOX=2504688.542848654%2C2504688.542848654%2C5009377.08569731%2C5009377.08569731 (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1131)')))
How can I disable checking this SSL verification or how can I handle this error (consequences after changing )? I am ready to change package code to handle this error. Everything was working when I was using HTTP connection.
I have already changed request.get(verify = False)
my code
import requests
requests.get('https://www.example.com:8080/geoserver/ows?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=qazqoinau_test%3A%D0%93%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0%20%D0%A0%D0%B5%D1%81%D0%BF%D1%83%D0%B1%D0%BB%D0%B8%D0%BA%D0%B8%20%D0%9A%D0%B0%D0%B7%D0%B0%D1%85%D1%81%D1%82%D0%B0%D0%BD&STYLES=qazqoinau_test%3Alayers_border_RK&SRS=EPSG%3A3857&CRS=EPSG%3A3857&TILED=true&access_token=JNkYj4bIfuWQbQu06AAF2MUxc9banx&WIDTH=512&HEIGHT=512&BBOX=2504688.542848654%2C2504688.542848654%2C5009377.08569731%2C5009377.08569731')

SSLError: HTTPSConnectionPool with "paddleocr"

I'm actually trying to use "paddleocr" with python
I use a conda environnement
i followed the guide on their github : https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.5/doc/doc_en/quickstart_en.md
But when i try to execute this command :
(paddle_env) C:\Windows\system32>paddleocr --image_dir "path\image" --use_angle_cls true --lang en --use_gpu false
i get this error :
download https://paddleocr.bj.bcebos.com/PP-OCRv3/english/en_PP-OCRv3_det_infer.tar to C:\Users\PD/.paddleocr/whl\det\en\en_PP-OCRv3_det_infer\en_PP-OCRv3_det_infer.tar
Traceback (most recent call last):
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn
conn.connect()
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\connection.py", line 414, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "C:\Users\PD\anaconda3\envs\paddle_env\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 "C:\Users\PD\anaconda3\envs\paddle_env\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\requests\adapters.py", line 489, in send
resp = conn.urlopen(
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
retries = retries.increment(
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\util\retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='paddleocr.bj.bcebos.com', port=443): Max retries exceeded with url: /PP-OCRv3/english/en_PP-OCRv3_det_infer.tar (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\PD\anaconda3\envs\paddle_env\Scripts\paddleocr.exe\__main__.py", line 7, in <module>
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\paddleocr\paddleocr.py", line 571, in main
engine = PaddleOCR(**(args.__dict__))
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\paddleocr\paddleocr.py", line 420, in __init__
maybe_download(params.det_model_dir, det_url)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\paddleocr\ppocr\utils\network.py", line 55, in maybe_download
download_with_progressbar(url, tmp_path)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\paddleocr\ppocr\utils\network.py", line 26, in download_with_progressbar
response = requests.get(url, stream=True)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\requests\api.py", line 73, in get
return request("get", url, params=params, **kwargs)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\requests\api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\requests\sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\requests\sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\requests\adapters.py", line 563, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='paddleocr.bj.bcebos.com', port=443): Max retries exceeded with url: /PP-OCRv3/english/en_PP-OCRv3_det_infer.tar (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)')))
paddleocr version : 2.5.0.3
python version : 3.8.13
It seems that you can not access the downlink provided by PaddleOCR, you can try to download the models on its mainpage, set rec_model_dir and det_model_dir mannually. (link)
demo image

SSL error after "download" call from yfinance

I installed yfinance in Spyder (Python 3.7) but when I make a basic call, such as:
import yfinance as yf
df_yahoo = yf.download('AAPL',
start='2000-01-01',
end='2010-12-31',
progress=False)
print(df_yahoo)
I get an error message:
Exception in thread Thread-9: Traceback (most recent call last):
File
"c:\users\miniconda3\lib\site-packages\urllib3\connectionpool.py",
line 672, in urlopen
chunked=chunked, File "c:\users/miniconda3\lib\site-packages\urllib3\connectionpool.py",
line 376, in _make_request
self._validate_conn(conn) File "c:\users\miniconda3\lib\site-packages\urllib3\connectionpool.py",
line 994, in validate_conn
conn.connect() File "c:\users\miniconda3\lib\site-packages\urllib3\connection.py",
line 360, in connect
ssl_context=context, File "c:\users\miniconda3\lib\site-packages\urllib3\util\ssl.py",
line 370, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname) File "c:\users\miniconda3\lib\ssl.py", line 423, in
wrap_socket
session=session File "c:\users\miniconda3\lib\ssl.py", line 870, in _create
self.do_handshake() File "c:\users\miniconda3\lib\ssl.py", line 1139, in do_handshake
self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed
certificate in certificate chain (_ssl.c:1076)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"c:\users\miniconda3\lib\site-packages\requests\adapters.py",
line 449, in send
timeout=timeout File "c:\users\miniconda3\lib\site-packages\urllib3\connectionpool.py",
line 720, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2] File
"c:\users\miniconda3\lib\site-packages\urllib3\util\retry.py",
line 436, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError:
HTTPSConnectionPool(host='query1.finance.yahoo.com', port=443): Max
retries exceeded with url:
/v8/finance/chart/AAPL?period1=946681200&period2=1293750000&interval=1d&includePrePost=False&events=div%2Csplits
(Caused by SSLError(SSLCertVerificationError(1, '[SSL:
CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed
certificate in certificate chain (_ssl.c:1076)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"c:\users\miniconda3\lib\threading.py", line 926, in
_bootstrap_inner
self.run() File "c:\users\miniconda3\lib\threading.py", line 870, in run
self._target(*self._args, **self.kwargs) File "c:\users\miniconda3\lib\site-packages\multitasking_init.py",
line 102, in _run_via_pool
return callee(*args, **kwargs) File "c:\users\miniconda3\lib\site-packages\yfinance\multi.py",
line 167, in _download_one_threaded
actions, period, interval, prepost, proxy, rounding) File "c:\users\miniconda3\lib\site-packages\yfinance\multi.py",
line 182, in _download_one
rounding=rounding, many=True) File "c:\users\miniconda3\lib\site-packages\yfinance\base.py",
line 150, in history
data = _requests.get(url=url, params=params, proxies=proxy) File "c:\users\miniconda3\lib\site-packages\requests\api.py",
line 76, in get
return request('get', url, params=params, **kwargs) File "c:\users\miniconda3\lib\site-packages\requests\api.py",
line 61, in request
return session.request(method=method, url=url, **kwargs) File "c:\users\miniconda3\lib\site-packages\requests\sessions.py",
line 530, in request
resp = self.send(prep, **send_kwargs) File "c:\users\miniconda3\lib\site-packages\requests\sessions.py",
line 643, in send
r = adapter.send(request, **kwargs) File "c:\users\miniconda3\lib\site-packages\requests\adapters.py",
line 514, in send
raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='query1.finance.yahoo.com', port=443): Max
retries exceeded with url:
/v8/finance/chart/AAPL?period1=946681200&period2=1293750000&interval=1d&includePrePost=False&events=div%2Csplits
(Caused by SSLError(SSLCertVerificationError(1, '[SSL:
CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed
certificate in certificate chain (_ssl.c:1076)')))
Moreover, Spyder seems to get stuck in some sort of loop and I have to manually interrupt it.
Can anyone help me here?
Many thanks
I believe the problem comes from an external source, maybe Yahoo Finance was down? I tried running your code and it works fine for me. (PyCharm, Python 3.7)
On MacOS Big Sur, You need to install the certificate in Python 3.9.
cd /Applications/Python\ 3.9/
./Install\ Certificates.command

OAuth 2.0 Connection reset by peer

I'm trying to connect to my api, but when I try to fetch access token () or just make a simple request to the endpoint /oauth/authorize, I receive this error :
Traceback (most recent call last):
File "venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 849, in _validate_conn
conn.connect()
File "venv/lib/python3.6/site-packages/urllib3/connection.py", line 356, in connect
ssl_context=context)
File "venv/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 372, in ssl_wrap_socket
return context.wrap_socket(sock)
File "/usr/lib/python3.6/ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "/usr/lib/python3.6/ssl.py", line 814, in __init__
self.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 1068, in do_handshake
self._sslobj.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "venv/lib/python3.6/site-packages/requests/adapters.py", line 445, in send
timeout=timeout
File "venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "venv/lib/python3.6/site-packages/urllib3/util/retry.py", line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='127.0.0.1', port=5000): Max retries exceeded with url: /oauth/authorize?response_type=code&client_id=&state=8SJIlHps6ehUrQhaKQ7h5ADS5o0CZo (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)'),))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "api.py", line 14, in <module>
session.fetch_access_token(uri)
File "venv/lib/python3.6/site-packages/authlib/client/oauth2_session.py", line 184, in fetch_access_token
withhold_token=True)
File "venv/lib/python3.6/site-packages/requests/sessions.py", line 559, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "venv/lib/python3.6/site-packages/authlib/client/oauth2_session.py", line 296, in request
method, url, auth=auth, **kwargs)
File "venv/lib/python3.6/site-packages/requests/sessions.py", line 512, in request
resp = self.send(prep, **send_kwargs)
File "venv/lib/python3.6/site-packages/requests/sessions.py", line 622, in send
r = adapter.send(request, **kwargs)
File "venv/lib/python3.6/site-packages/requests/adapters.py", line 511, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='127.0.0.1', port=5000): Max retries exceeded with url: /oauth/authorize?response_type=code&client_id=&state=8SJIlHps6ehUrQhaKQ7h5ADS5o0CZo (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)'),))
' Connection reset by peer ' socket error don't work to me. I'm using a https connection locally and the default server from Flask. Some tips ?
Update :
I did try to set the ssl of two ways :
1 º :
import ssl
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context.load_cert_chain('127.0.0.1+1.pem', '127.0.0.1+1-key.pem')
app.run(ssl_context=context)
2 º :
app.run(ssl_context=('127.0.0.1+1.pem', '127.0.0.1+1-key.pem'))

Python module googletrans throwing "Max retries exceeded with url: /" error

My Editor is PyCharm 2017.3 and my Python version is 3.4.
I trying to translate the word clicked on my application from english to hindi.
This application scraps words from a site and lists it.Everything is working fine with this application except the translation feature.
I have just installed googletrans library but it is giving me error that goes like max no of retries exceeded.
def translate(self):
translate=Translator()
translate.translate(self._word, dest="hi",src="en")
Here is my translate function and here is the documentation I am referring to.
This is my Error showing in console.
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen
chunked=chunked)
File "C:\Python34\lib\site-packages\urllib3\connectionpool.py", line 346, in _make_request
self._validate_conn(conn)
File "C:\Python34\lib\site-packages\urllib3\connectionpool.py", line 850, in _validate_conn
conn.connect()
File "C:\Python34\lib\site-packages\urllib3\connection.py", line 326, in connect
ssl_context=context)
File "C:\Python34\lib\site-packages\urllib3\util\ssl_.py", line 329, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Python34\Lib\ssl.py", line 344, in wrap_socket
_context=self)
File "C:\Python34\Lib\ssl.py", line 540, in __init__
self.do_handshake()
File "C:\Python34\Lib\ssl.py", line 767, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\requests\adapters.py", line 440, in send
timeout=timeout
File "C:\Python34\lib\site-packages\urllib3\connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Python34\lib\site-packages\urllib3\util\retry.py", line 388, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='translate.google.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)'),))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/ROCKSTAR/PycharmProjects/Dictionary/execute.py", line 56, in getPerWordDisplay
self.query.value(4), self.query.value(5))
File "C:\Users\ROCKSTAR\PycharmProjects\Dictionary\PerWordWindow.py", line 23, in __init__
self.translate()
File "C:\Users\ROCKSTAR\PycharmProjects\Dictionary\PerWordWindow.py", line 37, in translate
translate.translate(self._word, dest="hi",src="en")
File "C:\Python34\lib\site-packages\googletrans\client.py", line 132, in translate
data = self._translate(text, dest, src)
File "C:\Python34\lib\site-packages\googletrans\client.py", line 57, in _translate
token = self.token_acquirer.do(text)
File "C:\Python34\lib\site-packages\googletrans\gtoken.py", line 180, in do
self._update()
File "C:\Python34\lib\site-packages\googletrans\gtoken.py", line 57, in _update
r = self.session.get(self.host)
File "C:\Python34\lib\site-packages\requests\sessions.py", line 521, in get
return self.request('GET', url, **kwargs)
File "C:\Python34\lib\site-packages\requests\sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python34\lib\site-packages\requests\sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "C:\Python34\lib\site-packages\requests\adapters.py", line 506, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='translate.google.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)'),))
Process finished with exit code 0
It seems to be a connection error or maybe a certificate error. Its not a code error, Somehow the google server did not return a response. Try to wait some time or search for some kind of certificate, maybe they block too many requests to not overflow the server. The same issue happen to me and I wait 30min and the error was gone...

Categories