0
from py_translator import Translator

translator = Translator()

I try:

translator.translate("i am a boy", dest='es', src='en').text

This used to work a couple of days ago. Now, I get an error in:

/anaconda2/lib/python2.7/site-packages/py_translator/gtoken.py

self.tkk = self.RE_TKK.findall(r.text)[0]

IndexError: list index out of range
TrebledJ
  • 8,713
  • 7
  • 26
  • 48
  • `findall` isn't finding anything, check the code that parses the page, the error is there. – Pedro Lobito Dec 01 '18 at 04:37
  • Where is that code? – user5191561 Dec 01 '18 at 04:45
  • That's what you should post in your question. I've no idea ***where is the code***. Your comment doesn't make any sense. SO isn't a coding site, we're here to help, not to do your work. – Pedro Lobito Dec 01 '18 at 04:47
  • I thought you were referring to code in the py_translate package, not my code. I have posted my python code (just the 3 lines) in the question, which by the way would return 'soy un chico' a couple of days ago. – user5191561 Dec 01 '18 at 05:05

2 Answers2

1

Found the bug and fix here on github:

https://github.com/markolofsen/py_translator/pull/8/commits/410ccdcafdcc2a087b455b4e6a5eb7fef13f1c69

0

try this: pip install googletrans==3.1.0a0
or you can try this
pip install google_trans_new
reference
googletrans stopped working with error 'NoneType' object has no attribute 'group'

  • Hi Ayush and welcome to StackOverflow! Could you please format your code correctly? If you don't know how, here a [guide](https://meta.stackoverflow.com/questions/251361/how-do-i-format-my-code-blocks) for you – BiOS Mar 01 '21 at 14:30