gTTS python most basic example not working - python

I have this weird problem in which I just install gtts and write the following 3 lines of code
from gtts import gTTS
tts = gTTS('hello', tld='com')
tts.save('hello.mp3')
And it just doesn't work. It gives these errors
Traceback (most recent call last):
File "C:\Users\emanu\PycharmProjects\prove\venv\lib\site-packages\urllib3\connectionpool.py", line 700, in urlopen
self._prepare_proxy(conn)
File "C:\Users\emanu\PycharmProjects\prove\venv\lib\site-packages\urllib3\connectionpool.py", line 994, in _prepare_proxy
conn.connect()
File "C:\Users\emanu\PycharmProjects\prove\venv\lib\site-packages\urllib3\connection.py", line 364, in connect
self.sock = conn = self._connect_tls_proxy(hostname, conn)
File "C:\Users\emanu\PycharmProjects\prove\venv\lib\site-packages\urllib3\connection.py", line 499, in _connect_tls_proxy
socket = ssl_wrap_socket(
File "C:\Users\emanu\PycharmProjects\prove\venv\lib\site-packages\urllib3\util\ssl_.py", line 453, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
File "C:\Users\emanu\PycharmProjects\prove\venv\lib\site-packages\urllib3\util\ssl_.py", line 495, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock)
File "C:\Users\emanu\AppData\Local\Programs\Python\Python38\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\emanu\AppData\Local\Programs\Python\Python38\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Users\emanu\AppData\Local\Programs\Python\Python38\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
FileNotFoundError: [Errno 2] No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\emanu\PycharmProjects\prove\venv\lib\site-packages\requests\adapters.py", line 440, in send
resp = conn.urlopen(
File "C:\Users\emanu\PycharmProjects\prove\venv\lib\site-packages\urllib3\connectionpool.py", line 785, in urlopen
retries = retries.increment(
File "C:\Users\emanu\PycharmProjects\prove\venv\lib\site-packages\urllib3\util\retry.py", line 592, 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: /_/TranslateWebserverUi/data/batchexecute (Caused by ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\emanu\PycharmProjects\prove\venv\lib\site-packages\gtts\tts.py", line 265, in stream
r = s.send(
File "C:\Users\emanu\PycharmProjects\prove\venv\lib\site-packages\requests\sessions.py", line 645, in send
r = adapter.send(request, **kwargs)
File "C:\Users\emanu\PycharmProjects\prove\venv\lib\site-packages\requests\adapters.py", line 513, in send
raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='translate.google.com', port=443): Max retries exceeded with url: /_/TranslateWebserverUi/data/batchexecute (Caused by ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/emanu/PycharmProjects/prove/main.py", line 3, in <module>
tts.save('hello.mp3')
File "C:\Users\emanu\PycharmProjects\prove\venv\lib\site-packages\gtts\tts.py", line 329, in save
self.write_to_fp(f)
File "C:\Users\emanu\PycharmProjects\prove\venv\lib\site-packages\gtts\tts.py", line 310, in write_to_fp
for idx, decoded in enumerate(self.stream()):
File "C:\Users\emanu\PycharmProjects\prove\venv\lib\site-packages\gtts\tts.py", line 281, in stream
raise gTTSError(tts=self)
gtts.tts.gTTSError: Failed to connect. Probable cause: Unknown
Process finished with exit code 1
If I instead put
tld='co.uk'
It gives
gtts.tts.gTTSError: Failed to connect. Probable cause: Host 'https://translate.google.co.uk/' is not reachable
If I open both https://translate.google.co.uk/ or https://translate.google.com/ on my browser it works fine.
Can you please help me solve this issue?

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')

TimeoutError: [Errno 110] Connection timed out-Api testing

I am trying to run python behave feature file in python for API testing. The code works fine in Pycharm but not in Gitlab CI. It shows
Given Set Get Route api endpoint as /api/Tourist/26 # steps/stepImplementation.py:15
When we send GET HTTP Status request to api # steps/stepImplementation.py:21
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 95, in create_connection
raise err
File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 85, in create_connection
sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1040, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 358, in connect
self.sock = conn = self._new_conn()
File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 179, in _new_conn
raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x7f9936df5150>, 'Connection to kyc.api.prev.validatis.de timed out. (connect timeout=None)')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 440, in send
resp = conn.urlopen(
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 785, in urlopen
retries = retries.increment(
File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='kyc.api.prev.validatis.de', port=443): Max retries exceeded with url: /validatis/v1.16.0 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f9936df5150>, 'Connection to ---------- timed out. (connect timeout=None)'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/behave/model.py", line 1329, in run
match.run(runner.context)
File "/usr/local/lib/python3.10/site-packages/behave/matchers.py", line 98, in run
self.func(context, *args, **kwargs)
File "steps/stepImplementation.py", line 23, in step_impl
context.response = requests.get(context.url)
File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 529, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 645, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 507, in send
raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='kyc.api.prev.validatis.de', port=443): Max retries exceeded with url: ------ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f9936df5150>, 'Connection to ----------- timed out. (connect timeout=None)'))
Then The valid response of status code be 200 # None
Gitlab yml file
image: "python:3.10"
before_script:
python --version
pip install -r requirements.txt
stages:
- test
python_behave_tests:
stage: test
script:
- cd features
- behave TestApi.feature --no-capture
- behave GetApiOperationModeStatus.feature --no-capture
Is it the problem with my code or with the yml file or gitlab CI. But my code works in local environment.

Got ssl.SSLEOFError when working behind a vpn

I m working behind a vpn and trying to use python requests, but I keep getting ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1123). Once I turned down the vpn it worked as excepted. Is there any way to work around this issue?
Also one thing worth noting is that I tried to use postman while the vpn was on, and it worked fine.
Example
import requests
requests.get('https://www.google.com')
Traceback (most recent call last):
File "D:\Programming\Projects\Python\Scripts\venv\lib\site-packages\urllib3\connectionpool.py", line 700, in urlopen
self._prepare_proxy(conn)
File "D:\Programming\Projects\Python\Scripts\venv\lib\site-packages\urllib3\connectionpool.py", line 994, in _prepare_proxy
conn.connect()
File "D:\Programming\Projects\Python\Scripts\venv\lib\site-packages\urllib3\connection.py", line 364, in connect
conn = self._connect_tls_proxy(hostname, conn)
File "D:\Programming\Projects\Python\Scripts\venv\lib\site-packages\urllib3\connection.py", line 501, in _connect_tls_proxy
socket = ssl_wrap_socket(
File "D:\Programming\Projects\Python\Scripts\venv\lib\site-packages\urllib3\util\ssl_.py", line 453, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
File "D:\Programming\Projects\Python\Scripts\venv\lib\site-packages\urllib3\util\ssl_.py", line 495, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock)
File "D:\Programming\Python\Python39\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "D:\Programming\Python\Python39\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "D:\Programming\Python\Python39\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1123)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Programming\Projects\Python\Scripts\venv\lib\site-packages\requests\adapters.py", line 440, in send
resp = conn.urlopen(
File "D:\Programming\Projects\Python\Scripts\venv\lib\site-packages\urllib3\connectionpool.py", line 785, in urlopen
retries = retries.increment(
File "D:\Programming\Projects\Python\Scripts\venv\lib\site-packages\urllib3\util\retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1123)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Programming\Projects\Python\Scripts\crawling\util.py", line 197, in <module>
main()
File "D:\Programming\Projects\Python\Scripts\crawling\util.py", line 189, in main
requests.get('https://www.google.com')
File "D:\Programming\Projects\Python\Scripts\venv\lib\site-packages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "D:\Programming\Projects\Python\Scripts\venv\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "D:\Programming\Projects\Python\Scripts\venv\lib\site-packages\requests\sessions.py", line 529, in request
resp = self.send(prep, **send_kwargs)
File "D:\Programming\Projects\Python\Scripts\venv\lib\site-packages\requests\sessions.py", line 645, in send
r = adapter.send(request, **kwargs)
File "D:\Programming\Projects\Python\Scripts\venv\lib\site-packages\requests\adapters.py", line 517, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1123)')))
Thanks in advance.

pyTelegramBotAPI connection problem or what?

this is my code:
import telebot
bot = telebot.TeleBot(Token)
#bot.message_handler(commands=["greet"])
def greeting(message):
bot.reply_to(message, "Hi")
bot.polling()
and this is the error I receive:
Traceback (most recent call last):
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 696, in urlopen
self._prepare_proxy(conn)
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 964, in _prepare_proxy
conn.connect()
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connection.py", line 359, in connect
conn = self._connect_tls_proxy(hostname, conn)
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connection.py", line 496, in _connect_tls_proxy
return ssl_wrap_socket(
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util\ssl_.py", line 432, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util\ssl_.py", line 474, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock)
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util\retry.py", line 573, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot1494641875:AAEPX72rP7YFT0ZZzASh0cn9rAw6l8PUMk0/getUpdates?offset=1&timeout=20 (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:/Programming/Python/Training/TelegramBot02/main.py", line 13, in <module>
bot.polling()
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 455, in polling
self.__threaded_polling(none_stop, interval, timeout, long_polling_timeout)
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 513, in __threaded_polling
raise e
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 478, in __threaded_polling
polling_thread.raise_exceptions()
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\util.py", line 88, in raise_exceptions
raise self.exception_info
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\util.py", line 69, in run
task(*args, **kwargs)
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 295, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout, long_polling_timeout = long_polling_timeout)
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 265, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates, long_polling_timeout)
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\apihelper.py", line 248, in get_updates
return _make_request(token, method_url, params=payload)
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\apihelper.py", line 107, in _make_request
result = _get_req_session().request(
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "C:\Users\pc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot1494641875:AAEPX72rP7YFT0ZZzASh0cn9rAw6l8PUMk0/getUpdates?offset=1&timeout=20 (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123)')))
Connection is OK. Token is OK. It works manually when I browse https://api.telegram.org/botToken/getme and it works fine.
Other site for example google.com are OK too and works fine.
I would be glad to know what is the problem.
Actually because error I receive is too much a lot, stackoverflow does not allow me to post the question and wants me to add some more details, so I wrote this paragraph which is not related to the question and is just some words.
Do you have connected your telegram with a proxy? I can't solve your problem but you can follow this post: Problem connecting telegram bot through Python

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