5

I am trying to translate words from a Pandas dataframe column and get error in googletrans.Translator() class. It works normal with single words or phrases. Can it be environmental issue?

Any help or suggestions much appreciated

import pandas as pd 
from googletrans import Translator

translator = Translator()

df = pd.DataFrame({'Spanish':['piso','cama']})
df['English'] = df['Spanish'].apply(translator.translate, src='es', dest='en').apply(getattr, args=('text',))

Output:

AttributeError: 'Translator' object has no attribute 'raise_Exception'

2 Answers 2

5

Hi this error occured because there is an exception occurred in the runtime. To see the error insert this below code

python translator.raise_Exception = True If you get the error as below

Exception: Unexpected status code "429" from ['translate.google.com']

which means Too many requests. Hope you would not get this error. If so you have to upgrade you account. To avoid the error please refer this answer

Source 1

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, but yes, now I`m getting 429, trying to fix this)
You are welcome. I have attached a possible fix also in the answer.Can you please accept my answer.
-1

I faced the same problem. I changed the version of googletrans and it solved.

!pip install googletrans==3.1.0a0

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.