1

I am in the end of the powers. I get

    raise SSLError(e, request=request)
requests.exceptions.SSLError: (MaxRetryError("HTTPSConnectionPool(host='translate.google.com', port=443): Max retries exceeded with url: /m?tl=cs&sl=auto&q=hovno (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')))"), 'occurred at index 0')

in my code for Google Translate.

I tried:

page = requests.get("https://translate.google.com", verify=False)
# NO LUCK

page = requests.get("http://translate.google.com", proxies={"http": "http://111.233.225.166:1234"})
# NO LUCK

ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
resp = urlrq.urlopen('https://www.translate.google.com', context = ssl.create_default_context(cafile = certifi.where()))
ssl._create_default_https_context = ssl._create_unverified_context

#NO LUCK


_create_unverified_https_context = ssl._create_unverified_context

# NO LUCK

WHAT AM I DOING WRONG? Or does it have to have something with Company network?

I am desperate... I am trying to make user friendly translator from Excel for users to be easily accessible.

Whole code:

import requests
import pandas as pd
from deep_translator import GoogleTranslator
from openpyxl import load_workbook
import urllib.request as urlrq
import certifi
import ssl

#ctx = ssl.create_default_context()
#ctx.check_hostname = False
#ctx.verify_mode = ssl.CERT_NONE
#resp = urlrq.urlopen('https://www.translate.google.com', context = ssl.create_default_context(cafile = certifi.where()))
#ssl._create_default_https_context = ssl._create_unverified_context

def translate(term, lang):
    return GoogleTranslator(source='auto', target=lang).translate(text=term)

#_create_unverified_https_context = ssl._create_unverified_context
#page = requests.get("http://www.google.com:80", proxies={"http": "http://111.233.225.166:1234"})

page = requests.get("https://translate.google.com", verify=False)

lang=['cs','fr','nl','de','hu','pl','pt','ro','sk','es']

# Load workbook
wb = load_workbook('C:\Test\Translation.xlsm')
# load sheet
ws = wb['Input']

data = ws.values
columns = next(data)[0:]
# Convert to DataFrame
df = pd.DataFrame(data, columns=columns)

df.loc[:, 'lang']=df.Description.apply(lambda x : lang)
df = df.explode("lang")
df.loc[:, "translation"] = df.loc[:, ["Description" , "lang"]].apply(lambda x : translate(*x), axis=1)

df.to_excel(sheet_name='Output', index=False)
HeadOverFeet
  • 768
  • 6
  • 13
  • 33
  • I had much trouble with my company's antivirus (kaspersky). It created autosigned SSL certificates making any ssl transaction impossible (excepted in web browsers). Do you have any other SSL related issues (like using pip install) ? Have you verified your proxy setup ? – Grall Apr 05 '22 at 16:40
  • Why do you create `page` at all? It is never accessed and not necessary for your lambda. Is the `deep_translator` part working for you? Other than that, your code ran fine in my [Colab Notebook](https://colab.research.google.com/drive/1zJgc4jT-JxJUDNMZzLNrt5_MAL9mngwM?usp=sharing) – KarelZe Apr 05 '22 at 16:55
  • Hi, pip install works fine…. on page variable - well… I thought it will work. Maybe that is issue that I dont actually use the “page variable?”. Stupid Q - but how shall I make a use of it?I am brainwashed I guess… – HeadOverFeet Apr 05 '22 at 20:38
  • How can I verify the setuo? today I was told that we use ZScaler and it works fine… but… not for my purposes. I am sooo lost. This network topic is complete jungle – HeadOverFeet Apr 05 '22 at 20:43
  • I used the page variabke as I saw it here https://stackoverflow.com/questions/51768496/why-do-https-requests-produce-ssl-certificate-verify-failed-error – HeadOverFeet Apr 05 '22 at 20:45
  • Did this issue got resolved for you? – Shashank Srivastava May 24 '23 at 13:34

0 Answers0