Python google translate error

I was trying googletrans and it was working quite well. Since this morning I started getting below error. I went through multiple posts from stackoverflow and other sites and found probably my ip is

I was trying googletrans and it was working quite well. Since this morning I started getting below error. I went through multiple posts from stackoverflow and other sites and found probably my ip is banned to use the service for sometime. I tried using multiple service provider internet that has different ip and stil facing the same issue ? I also tried to use googletrans on different laptops , still same issue ..Is googletrans package broken or something google did at their end ?

>>> from googletrans import Translator
>>> translator = Translator()
>>> translator.translate('안녕하세요.')

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    translator.translate('안녕하세요.')
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/googletrans/client.py", line 172, in translate
    data = self._translate(text, dest, src)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/googletrans/client.py", line 75, in _translate
    token = self.token_acquirer.do(text)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/googletrans/gtoken.py", line 180, in do
    self._update()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/googletrans/gtoken.py", line 59, in _update
    code = unicode(self.RE_TKK.search(r.text).group(1)).replace('var ', '')
AttributeError: 'NoneType' object has no attribute 'group'

Stevoisiak's user avatar

Stevoisiak

22.1k27 gold badges119 silver badges216 bronze badges

asked Sep 22, 2018 at 10:29

steveJ's user avatar

3

Update 06.12.20: A new ‘official’ alpha version of googletrans with a fix was released

Install the alpha version like this:

pip install googletrans==3.1.0a0

Translation example:

translator = Translator()
translation = translator.translate("Der Himmel ist blau und ich mag Bananen", dest='en')
print(translation.text)
#output: 'The sky is blue and I like bananas'

In case it does not work, try to specify the service url like this:

from googletrans import Translator
translator = Translator(service_urls=['translate.googleapis.com'])
translator.translate("Der Himmel ist blau und ich mag Bananen", dest='en')

See the discussion here for details and updates: https://github.com/ssut/py-googletrans/pull/237

Update 10.12.20: Another fix was released

As pointed out by @DesiKeki and @Ahmed Breem, there is another fix which seems to work for several people:

pip install googletrans==4.0.0-rc1

Github discussion here: https://github.com/ssut/py-googletrans/issues/234#issuecomment-742460612

In case the fixes above don’t work for you

If the above doesn’t work for you, google_trans_new seems to be a good alternative that works for some people. It’s unclear why the fix above works for some and doesn’t for others. See details on installation and usage here: https://github.com/lushan88a/google_trans_new

#pip install google_trans_new

from google_trans_new import google_translator  
translator = google_translator()  
translate_text = translator.translate('สวัสดีจีน',lang_tgt='en')  
print(translate_text)
#output: Hello china

answered Dec 2, 2020 at 13:46

Moritz's user avatar

MoritzMoritz

2,5152 gold badges6 silver badges11 bronze badges

11

Update 01/12/2020: This issue re-emerged lately, (apparently) caused once again by some changes on the Google translation API.

A solution is being discussed (again) in this Github issue. Although there is not a definitive solution yet a Pull Request seem to be solving the problem: https://github.com/ssut/py-googletrans/pull/237.

While we wait for it to be approved it can be installed like 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

Original Answer:

Apparently it’s a recent and widespread problem on Google’s side.
Quoting various Github discussions, it happens when Google sends you directly the raw token.

It’s being discussed right now and there is already a pull request to fix it, so it should be resolved in the next few days.

For reference, see:

https://github.com/ssut/py-googletrans/issues/48 <— exact same problem reported on the Github repo
https://github.com/pndurette/gTTS/issues/60 <— seemingly same problem on a text-to-speech library
https://github.com/ssut/py-googletrans/pull/78 <— pull request to fix the issue

To apply this patch (without waiting for the pull request to be accepted) simply install the library from the forked repo https://github.com/BoseCorp/py-googletrans.git (uninstall the official library first):

$ pip uninstall googletrans
$ git clone https://github.com/BoseCorp/py-googletrans.git
$ cd ./py-googletrans
$ python setup.py install

You can clone it anywhere on your system and install it globally or while inside a virtualenv.

answered Sep 22, 2018 at 11:23

Maldus's user avatar

MaldusMaldus

9,6744 gold badges22 silver badges35 bronze badges

18

Try google_trans_new. It solved the problem for me
https://github.com/lushan88a/google_trans_new

pip install google_trans_new

from google_trans_new import google_translator  
  
translator = google_translator()  
translate_text = translator.translate('Hola mundo!', lang_src='es', lang_tgt='en')  
print(translate_text)
-> Hello world!

Ian's user avatar

Ian

3,3863 gold badges27 silver badges59 bronze badges

answered Dec 2, 2020 at 17:31

Frederick van Lingen's user avatar

2

Updated Answer as of 2021 Sept

pip uninstall googletrans==4.0.0-rc1

pip install googletrans==3.1.0a0

The 3.1.0a0 version works with bulk translation too!

answered Sep 21, 2021 at 14:51

Harrish Selvarajah's user avatar

4

Unfortunately, I could get neither googletrans nor google_trans_new to work, despite the many proposed fixes that are around.

My solution was to switch to the deep_translator package:

pip install -U deep-translator

Then you can use it like this:

>>> from deep_translator import GoogleTranslator
>>> GoogleTranslator(source='auto', target='de').translate("keep it up, you are awesome") 
'weiter so, du bist toll'

See documentation for more info.

answered Jun 29, 2022 at 22:17

buddemat's user avatar

buddematbuddemat

3,90613 gold badges23 silver badges47 bronze badges

3

Update 10.12.20: New Alpha Version Release (Stable Release Candidate) is released: 4.0.0-rc1

It can be installed as follows:

pip install googletrans==4.0.0-rc1

Usage:

translation = translator.translate('이 문장은 한글로 쓰여졌습니다.', dest='en')
print(translation.text)
>>This sentence is written in Korean.
detected_lang = translator.detect('mein english me hindi likh raha hoon')
print(detected_lang)
>>Detected(lang=hi, confidence=None)
detected_lang = translator.detect('이 문장은 한글로 쓰여졌습니다.')
print(detected_lang)
>>Detected(lang=ko, confidence=None)

answered Dec 21, 2020 at 2:36

DesiKeki's user avatar

DesiKekiDesiKeki

5966 silver badges8 bronze badges

4

By the time of this answer, you can solve it with the following:

Uninstall your installed version of

pip uninstall googletrans

Install the following version

pip install googletrans==4.0.0rc1

I hope this will works for you as it worked for me.

You can try it now:

from googletrans import Translator
translator = Translator()
ar = translator.translate('مرحبا').text
print(ar)

Note that 4.0.0rc1 is using an old version of httpx, if you are getting an error regarding that, you need to edit the file client.py, fix httpcore.SyncHTTPTransport to httpcore.AsyncHTTPProxy.

answered Jun 7, 2021 at 15:31

AKMalkadi's user avatar

AKMalkadiAKMalkadi

5921 gold badge4 silver badges13 bronze badges

5

Here is an unofficial fix to this problem as Darkblader24 stated in: https://github.com/ssut/py-googletrans/pull/78

Update gtoken.py like this:

    RE_TKK = re.compile(r'TKK=eval('((function(){(.+?)})())');',
                        re.DOTALL)
    RE_RAWTKK = re.compile(r'TKK='([^']*)';',re.DOTALL)

    def __init__(self, tkk='0', session=None, host='translate.google.com'):
        self.session = session or requests.Session()
        self.tkk = tkk
        self.host = host if 'http' in host else 'https://' + host

    def _update(self):
        """update tkk
        """
        # we don't need to update the base TKK value when it is still valid
        now = math.floor(int(time.time() * 1000) / 3600000.0)
        if self.tkk and int(self.tkk.split('.')[0]) == now:
            return

        r = self.session.get(self.host)

        rawtkk = self.RE_RAWTKK.search(r.text)
        if rawtkk:
            self.tkk = rawtkk.group(1)
            return

answered Sep 24, 2018 at 20:49

Kerem's user avatar

KeremKerem

1,4532 gold badges15 silver badges27 bronze badges

1

Fixed is here https://pypi.org/project/py-translator/

$ pip3 install py_translator==1.8.9

from py_translator import Translator
s = Translator().translate(text='Hello my friend', dest='es').text
print(s)

out:Hola mi amigo

סטנלי גרונן's user avatar

סטנלי גרונן

2,87923 gold badges48 silver badges66 bronze badges

answered Nov 18, 2018 at 14:35

Georgi Ivanov Dimitrov's user avatar

0

pip uninstall googletrans googletrans-temp
pip install googletrans-temp

Worked for me in Win10 and Ubuntu 16 (Python 3.6) as of 2019.2.24 — Refer to one of the replies in https://github.com/ssut/py-googletrans/issues/94. The old fix pip install git+https://github.com/BoseCorp/py-googletrans.git --upgrade does not work any more over here.

answered Oct 19, 2018 at 4:18

mikey's user avatar

mikeymikey

1,9401 gold badge19 silver badges22 bronze badges

3

googletrans is not supported in latest python so you need to unistall it

install new googletrans ( pip install googletrans==3.1.0a0)

answered Jul 21, 2021 at 14:41

parveen mittal's user avatar

This is how I fixed my problem.

pip3 uninstall googletrans
pip3 install googletrans==3.1.0a0

First you need to uninstall the previous version and the install the 3.1.0 version.

Dharman's user avatar

Dharman

29.4k21 gold badges80 silver badges131 bronze badges

answered Oct 13, 2021 at 1:38

Sadia Anjum's user avatar

Use the translators package from here

  1. It works (;
  2. Supports more then google

Installation:

pip install translators --upgrade

Usage:


    >>> import translators as ts
    Using Israel server backend.
    >>> ts.google('שלום' , to_language = 'es')
    'Hola'
    

answered Feb 13, 2022 at 9:23

ניר's user avatar

נירניר

1,0161 gold badge6 silver badges27 bronze badges

Making the following change to gtoken made it work for me:

RE_TKK = re.compile(r'tkk:'(.+?)'')      

def __init__(self, tkk='0', session=None, host='translate.google.com'):
    self.session = session or requests.Session()
    self.tkk = tkk
    self.host = host if 'http' in host else 'https://' + host

def _update(self):
    """update tkk
    """
    # we don't need to update the base TKK value when it is still valid
    r = self.session.get(self.host)        

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

    now = math.floor(int(time.time() * 1000) / 3600000.0)
    if self.tkk and int(self.tkk.split('.')[0]) == now:
        return

    # this will be the same as python code after stripping out a reserved word 'var'
    code = unicode(self.RE_TKK.search(r.text).group(1)).replace('var ', '')
    # unescape special ascii characters such like a x3d(=)

I obtained this snippet from the ticket here.

Note that this is slightly different from other change suggested earlier by Kerem.

For other uninitiated folks like me, gtoken.py can be found within AppDataLocalContinuumanaconda3site-packagesgoogletrans on a Windows machine using Anaconda. To find AppData, go into the address bar in file explorer, type ‘%AppData%’, and hit Enter.

answered Mar 28, 2019 at 16:12

Neelotpal Shukla's user avatar

It turns out putting the call whithin a try/except block solved the problem for me

try:
    langs = translator.detect(update.message.text)
    if langs.lang == 'en':
        foo(translator.translate(update.message.text,dest='zh-cn').text)
    else:
        bar(translator.translate(update.message.text,dest='en').text)
except Exception as e:
    print(e)

answered May 17, 2020 at 20:24

malem's user avatar

malemmalem

513 bronze badges

If you are using Google Colab or Jupyter Notebook, then run:

!pip uninstall googletrans

Restart the runtime, and then execute:

!pip install googletrans==4.0.0rc1

Azhar Khan's user avatar

Azhar Khan

3,8068 gold badges26 silver badges32 bronze badges

answered Nov 25, 2022 at 6:48

Adarsh D's user avatar

Try — pip install googletrans==3.1.0a0

answered Sep 16, 2022 at 18:29

Anupama V Iyengar's user avatar

Содержание

  1. Что делать при ошибке при переводе через googletrans?
  2. Googletrans: Free and Unlimited Google translate API for Python¶
  3. Features¶
  4. Note on library usage¶
  5. Quickstart¶
  6. HTTP/2 support¶
  7. Basic Usage¶
  8. Customize service URL¶
  9. Advanced Usage (Bulk)¶
  10. Language detection¶
  11. API Guide¶
  12. googletrans.Translator¶
  13. googletrans.models¶
  14. googletrans.gtoken¶
  15. googletrans.LANGUAGES¶
  16. googletrans.DEFAULT_SERVICE_URLS¶
  17. Saravananslb/py-googletranslation
  18. Sign In Required
  19. Launching GitHub Desktop
  20. Launching GitHub Desktop
  21. Launching Xcode
  22. Launching Visual Studio Code
  23. Latest commit
  24. Git stats
  25. Files
  26. README.rst
  27. About

Что делать при ошибке при переводе через googletrans?

В чём проблема, помогите.

  • Вопрос задан 04 февр. 2022
  • 499 просмотров

Простой 1 комментарий

AttributeError: ‘NoneType’ object has no attribute ‘group’
Интерпретатор пытается к NoneType применить метод group(), у NoneType нет такого метода, ошибка в этой строке:
code = self.RE_TKK.search(r.text).group(1).replace(‘var ‘, »)
.group применяется к self.RE_TKK.search(r.text), данными тут является r.text
если проследить выше, получается что текст был получен сначала из self.token_acquirer.do(text), сюда попал из self._translate(text, dest, src, kwargs), куда был отправлен из translator.translate(_text_, dest=lang), куда был засунут из transl(d, l).

Судя по тому, что написано в выложенном тобой логе, ошибка возникает из-за не корректного d в transl(d, l)
Видно, что d у тебя выходит из input с клавиатуры. Инпут из клавы это строка по умолчанию, но никак не NoneType.
варианты такие:у тебя каким-то образом из input приходит не строка а nonetype, либо где-то в процессе твоя строка превращается в NoneType.

первое — замени input на любой string, и посмотри, будет ли работать, например: d = ‘bridge’

з.ы. за такой нейминг тебя по рукам будут бить палкой, никому не интересны эти d, l, s, mm, aa, aaaa. Когда разберёшься с проблемой, переименуй переменные в человекочитаемые, приучайся сразу.

Источник

Googletrans: Free and Unlimited Google translate API for Python¶

Googletrans is a free and unlimited python library that implemented Google Translate API. This uses the Google Translate Ajax API to make calls to such methods as detect and translate.

Features¶

  • Fast and reliable — it uses the same servers that translate.google.com uses
  • Auto language detection
  • Bulk translations
  • Customizable service URL
  • Connection pooling (the advantage of using requests.Session)
  • HTTP/2 support

Note on library usage¶

  • The maximum character limit on a single text is 15k.
  • Due to limitations of the web version of google translate, this API does not guarantee that the library would work properly at all times. (so please use this library if you don’t care about stability.)
  • If you want to use a stable API, I highly recommend you to use Google’s official translate API.
  • If you get HTTP 5xx error or errors like #6, it’s probably because Google has banned your client IP address.

Quickstart¶

You can install it from PyPI:

HTTP/2 support¶

This is a great deal for everyone! (up to 2x times faster in my test) If you want to get googletrans faster you should install hyper package. Googletrans will automatically detect if hyper is installed and if so, it will be used for http networking.

Basic Usage¶

If source language is not given, google translate attempts to detect the source language.

Customize service URL¶

You can use another google translate domain for translation. If multiple URLs are provided it then randomly chooses a domain.

Advanced Usage (Bulk)¶

Array can be used to translate a batch of strings in a single method call and a single HTTP session. The exact same method shown above work for arrays as well.

Language detection¶

The detect method, as its name implies, identifies the language used in a given sentence.

API Guide¶

googletrans.Translator¶

Google Translate ajax API implementation class

You have to create an instance of Translator to use this API

Parameters:
  • service_urls (a sequence of strings) – google translate url list. URLs will be used randomly. For example [‘translate.google.com’, ‘translate.google.co.kr’]
  • user_agent ( str ) – the User-Agent header to send when making requests.
  • proxies (dictionary) – proxies configuration. Dictionary mapping protocol or protocol and host to the URL of the proxy For example <‘http’: ‘foo.bar:3128’, ‘http://host.name’: ‘foo.bar:4012’>
  • timeout (numberora double of numbers) – Definition of timeout for httpx library. Will be used for every request.
  • proxies – proxies configuration. Dictionary mapping protocol or protocol and host to the URL of the proxy For example <‘http’: ‘foo.bar:3128’, ‘http://host.name’: ‘foo.bar:4012’>
  • raise_exception (boolean) – if True then raise exception if smth will go wrong

translate ( text, dest=’en’, src=’auto’, **kwargs ) ¶

Translate text from source language to destination language

list (when a list is passed)

Parameters:
  • text (UTF-8 str ; unicode ; string sequence (list, tuple, iterator, generator)) – The source text(s) to be translated. Batch translation is supported via sequence input.
  • dest – The language to translate the source text into. The value should be one of the language codes listed in googletrans.LANGUAGES or one of the language names listed in googletrans.LANGCODES .
  • dest – str ; unicode
  • src – The language of the source text. The value should be one of the language codes listed in googletrans.LANGUAGES or one of the language names listed in googletrans.LANGCODES . If a language is not specified, the system will attempt to identify the source language automatically.
  • src – str ; unicode
Return type:

Basic usage:

Detect language of the input text

Parameters: text (UTF-8 str ; unicode ; string sequence (list, tuple, iterator, generator)) – The source text(s) whose language you want to identify. Batch detection is supported via sequence input.
Return type: Detected
Return type: list (when a list is passed)

Basic usage:

googletrans.models¶

Translate result object

Parameters:
  • src – source language (default: auto)
  • dest – destination language (default: en)
  • origin – original text
  • text – translated text
  • pronunciation – pronunciation

class googletrans.models. Detected ( lang, confidence, **kwargs ) ¶

Language detection result object

Parameters:
  • lang – detected language
  • confidence – the confidence of detection result (0.00 to 1.00)

googletrans.gtoken¶

This is for internal use only to generate a valid token to access translate.google.com ajax API.

Google Translate API token generator

translate.google.com uses a token to authorize the requests. If you are not Google, you do have this token and will have to pay for use. This class is the result of reverse engineering on the obfuscated and minified code used by Google to generate such token.

The token is based on a seed which is updated once per hour and on the text that will be translated. Both are combined — by some strange math — in order to generate a final token (e.g. 744915.856682) which is used by the API to validate the request.

This operation will cause an additional request to get an initial token from translate.google.com.

googletrans.LANGUAGES¶

iso639-1 language codes for supported languages for translation. Some language codes also include a country code, like zh-CN or zh-TW.

googletrans.DEFAULT_SERVICE_URLS¶

DEFAULT_SERVICE_URLS is the list of current available Google Translation service urls.

For using these service urls, please check Customize service URL.

Источник

Saravananslb/py-googletranslation

Use Git or checkout with SVN using the web URL.

Work fast with our official CLI. Learn more.

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.rst

Unlimited Text Translation (no limitation)

pygoogletranslation is a free and unlimited python library that implemented Google Translate API. This uses the Google Translate Ajax API to make calls to such methods as detect and translate.

Compatible with Python 3.6+.

  • Translation from file (.doc, .docx, .pdf, .txt)
  • Fast and reliable — it uses the same servers that translate.google.com uses
  • Auto language detection
  • Bulk translations
  • Request

more features are coming soon.

  • Proxy support
  • Internal session management (for better bulk translations)

Python Request Module

This library uses request to get an data from google.

Request : POST GET

How does this library work

You may wonder how this library works properly, whereas other python translation package use the token mechanism but that is failling because google has changed their token mechanism.

To install, either use things like pip with the package «pygoogletranslation» or download the package and put the «pygoogletranslation» directory into your python path.

If source language is not given, google translate attempts to detect the source language.

Customize proxy URL

You can use proxies in the translation.

Advanced Usage (Bulk)

Array can be used to translate a batch of strings in a single method call and a single HTTP session. The exact same method shown above works for arrays as well.

The detect method, as its name implies, identifies the language used in a given sentence.

Translation from document (.doc, .docx, .pdf, .txt):

pygoogletranslation to get Language and Language Codes

Note on library usage

DISCLAIMER: this is an unofficial library using the web API of translate.google.com and also is not associated with Google.

  • Due to limitations of the web version of google translate, this API does not guarantee that the library would work properly at all times (so please use this library if you don’t care about stability).
  • Important: If you want to use a stable API, I highly recommend you to use Google’s official translate API.
  • If you get HTTP 5xx error or errors like #6, it’s probably because Google has banned your client IP address.

This library follows Semantic Versioning from v2.0.0. Any release versioned 0.x.y is subject to backwards incompatible changes at any time.

Contributions are more than welcomed. See CONTRIBUTING.md

pygoogletranslation is licensed under the MIT License. The terms are as follows:

Copyright (c) 2021 Saravananslb

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the «Software»), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED «AS IS», WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

pygoogletranslation: Free and Unlimited Google translate API for Python. Translates totally free of charge.

Источник

Hello Guys, How are you all? Hope You all Are Fine. Today I am trying to use googletrans but I am facing following error googletrans AttributeError: ‘NoneType’ object has no attribute ‘group’ in Java. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

Contents

  1. How googletrans AttributeError: ‘NoneType’ object has no attribute ‘group’ Error Occurs ?
  2. How To Solve googletrans AttributeError: ‘NoneType’ object has no attribute ‘group’ Error ?
  3. Solution 1: Install latest version of googletrans
  4. Solution 2: Use google_trans_new
  5. Solution 3: Use this command
  6. Summary

I am trying to use googletrans but I am facing following error.

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    translator.translate('Hola como estas ?')
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/googletrans/client.py", line 172, in translate
    data = self._translate(text, dest, src)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/googletrans/client.py", line 75, in _translate
    token = self.token_acquirer.do(text)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/googletrans/gtoken.py", line 180, in do
    self._update()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/googletrans/gtoken.py", line 59, in _update
    code = unicode(self.RE_TKK.search(r.text).group(1)).replace('var ', '')
AttributeError: 'NoneType' object has no attribute 'group'

How To Solve googletrans AttributeError: ‘NoneType’ object has no attribute ‘group’ Error ?

  1. How To Solve googletrans AttributeError: ‘NoneType’ object has no attribute ‘group’ Error ?

    To Solve googletrans AttributeError: ‘NoneType’ object has no attribute ‘group’ Error Install latest version of googletrans or Just use this version pip install googletrans==4.0.0-rc1 Now you can use google translate.

  2. googletrans AttributeError: ‘NoneType’ object has no attribute ‘group’

    To Solve googletrans AttributeError: ‘NoneType’ object has no attribute ‘group’ Error Install latest version of googletrans or Just use this version pip install googletrans==4.0.0-rc1 Now you can use google translate.

Solution 1: Install latest version of googletrans

Install latest version of googletrans or Just use this version.

pip install googletrans==4.0.0-rc1

Now you can use google translate.

translator = Translator()
translation = translator.translate("Hola como estas ?", dest='en')
print(translation.text)
#output: 'Hello How are you ?'

Solution 2: Use google_trans_new

Just use google_trans_new. To install use this command.

pip install google_trans_new

Here is simple Example.

from google_trans_new import google_translator  
  
translator = google_translator()  
translate_text = translator.translate('Hola mundo!', lang_src='es', lang_tgt='en')  
print(translate_text)
-> Hello world!

Solution 3: Use this command

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

Summary

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

  • ImportError: No module named _internal

Понравилась статья? Поделить с друзьями:
  • Python base64 binascii error incorrect padding
  • Pytest error not found
  • Pygame error unsupported image format
  • Pygame error failed loading libvorbisfile 3 dll не найден указанный модуль
  • Pycharm ошибка интерпретатора