-1

I want to translate text from one language to english using google translator in Python. I am using google colab for writing code.
translations[element] = translator.translate(element).text. i am getting attribute error. AttributeError: 'NoneType' object has no attribute 'group'

  • Please provide a [mcve], as well as the entire error output. Have you done any debugging? – AMC May 12 '21 at 15:01

1 Answers1

1

i don't know google colab but they are a lot of tutorials

https://pypi.org/project/googletrans/

It's one of the example of this:

>>> from googletrans import Translator
>>> translator = Translator()
>>> translator.detect('이 문장은 한글로 쓰여졌습니다.')
# <Detected lang=ko confidence=0.27041003>
>>> translator.detect('この文章は日本語で書かれました。')
# <Detected lang=ja confidence=0.64889508>
>>> translator.detect('This sentence is written in English.')
# <Detected lang=en confidence=0.22348526>
>>> translator.detect('Tiu frazo estas skribita en Esperanto.')
# <Detected lang=eo confidence=0.10538048>

I'm sorry, it's the first time i answer on stack overflow. U can send your code, to check your error

pgmendormi
  • 184
  • 2
  • 12
  • translator.detect('이 문장은 한글로 쓰여졌습니다.') Getiing error for this line as AttributeError: 'NoneType' object has no attribute 'group' – Anuja Kulkarni May 12 '21 at 09:19
  • try this: ``` $ pip uninstall googletrans $ git clone https://github.com/alainrouillon/py-googletrans.git $ cd ./py-googletrans $ git checkout origin/feature/enhance-use-of-direct-api $ python setup.py install ``` i had the same issue and used this stack overflow: https://stackoverflow.com/questions/52455774/googletrans-stopped-working-with-error-nonetype-object-has-no-attribute-group – pgmendormi May 12 '21 at 09:48