Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'group' #286

Closed
Itz-MrJ opened this issue Apr 10, 2021 · 23 comments
Closed

AttributeError: 'NoneType' object has no attribute 'group' #286

Itz-MrJ opened this issue Apr 10, 2021 · 23 comments
Labels

Comments

@Itz-MrJ
Copy link

Itz-MrJ commented Apr 10, 2021

I'm using one of the basic code:

from googletrans import Translator

translator = Translator()

translation=translator.translate('안녕하세요.', dest='ja')

print(translation)

And I'm getting an attribute error :
AttributeError: 'NoneType' object has no attribute 'group'

Please let me know if the module is still working properly.

@YuvalPruss
Copy link

Came across this as well 👍🏻

@ZhymabekRoman
Copy link

Solution:

$ pip3 uninstall googletrans
$ pip3 install googletrans==3.1.0a0

@theoyuandawang
Copy link

Solution:

$ pip3 uninstall googletrans
$ pip3 install googletrans==3.1.0a0

have not fixed yet

@ZhymabekRoman
Copy link

Solution:

$ pip3 uninstall googletrans
$ pip3 install googletrans==3.1.0a0

have not fixed yet

I don't even know why it didn't work for you, but it helped me

@Itz-MrJ
Copy link
Author

Itz-MrJ commented Apr 14, 2021

Any other solution guys please?

@Princelwd
Copy link

Solution:

$ pip3 uninstall googletrans
$ pip3 install googletrans==3.1.0a0

Worked for me, thank you :)

@roflcoopter

This comment has been minimized.

@dkbrz
Copy link

dkbrz commented Apr 21, 2021

It solved the problem, but it doesn't translate anything now.

@jbakerr
Copy link

jbakerr commented Apr 22, 2021

I'm having the same issue as @dkbrz .

If i run:


translator = Translator()

translation=translator.translate('안녕하세요.', dest='ja')

print(translation.text)

it is returning the original string - untranslated: '안녕하세요'

@ZhymabekRoman
Copy link

@jbakerr @dkbrz I checked myself personally on my computer - everything works perfectly:
image

@JoyceXu02
Copy link

Try "import googletrans" and "translator = googletrans.Translator()". It works in my case.

@gaetan1903
Copy link

Solution:

$ pip3 uninstall googletrans
$ pip3 install googletrans==3.1.0a0

Works for me 🥇

@trimbilrepo
Copy link

you need to check that others dependencies is compatible with your current version.
such as:

h2 version h2 3.2.0
hyperframe 5.2.0

check your pip version, update if require then do:

$ pip3 uninstall googletrans
$ pip3 install googletrans

@bekha-io
Copy link

Hum..... the problem has not been solved yet. After reinstalling the library from latest version to 3.1.0a0, 'dest' parameter doesn't work. When you're trying to translate 'hello', despite selected destination langauge, you get the source text again....

@BelenAleman
Copy link

Solution:

$ pip3 uninstall googletrans
$ pip3 install googletrans==3.1.0a0

have not fixed yet

I don't even know why it didn't work for you, but it helped me

It also solved my issue. Thanks

@FurkanToprak
Copy link

Solution:

$ pip3 uninstall googletrans
$ pip3 install googletrans==3.1.0a0

When will the default pip3 branch default to this version?

@caas1729
Copy link

caas1729 commented May 30, 2021

Hum..... the problem has not been solved yet. After reinstalling the library from latest version to 3.1.0a0, 'dest' parameter doesn't work. When you're trying to translate 'hello', despite selected destination langauge, you get the source text again....

Same here. Any solutions to this, guys?

@GooseterV
Copy link

Solution:

$ pip3 uninstall googletrans
$ pip3 install googletrans==3.1.0a0

Thanks for this, worked fine

@un33k
Copy link

un33k commented Jul 7, 2021

The issue is due to a failure followed by an invalid execution path that is not handled properly .. it seems.

Ref: jtoken.py

  # in jtoken file (orig)
  raw_tkk = self.RE_TKK.search(r.text)
  if raw_tkk:
    self.tkk = raw_tkk.group(1)
    return

    code = self.RE_TKK.search(r.text).group(1).replace('var ', '')
  # in jtoken file (modified)
  raw_tkk = self.RE_TKK.search(r.text)
  if raw_tkk:
    self.tkk = raw_tkk.group(1)
    return

    # we already called search() so let's just use the result which is raw_tkk
    code = raw_tkk.group(1).replace('var ', '')

As it can be noticed from the above two, which logically are equal

# raw_tkk is the result of calling self.RE_TKK.search(r.text)

raw_tkk = self.RE_TKK.search(r.text)

# If raw_tkk is valid, it return from the function as follow 
 if raw_tkk:
    self.tkk = raw_tkk.group(1)
    return

# If it is not valid, it does run
code = self.RE_TKK.search(r.text).group(1).replace('var ', '')

# which is equal to 
code = raw_tkk.group(1).replace('var ', '')

# But we know we are there due to an invalid `raw_tkk`, and one cannot call `.group(1)` on an a NoneType `raw_tkk`.

Furthermore, I dump the repose text r.text and I noticed it looked like an error page in html, so the api is probably failing.
Hope the above can help with a fix in RC2.

Also related

@RutujaWanjari
Copy link

Does not resolve the issue even after installing version 3.1.0a0

@shawon922
Copy link

Solution:

$ pip3 uninstall googletrans
$ pip3 install googletrans==3.1.0a0

It resolved my issue. Thanks.

@stale
Copy link

stale bot commented Oct 8, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Oct 8, 2021
@573271137
Copy link

Solution:

$ pip3 uninstall googletrans
$ pip3 install googletrans==3.1.0a0

it's good for me

@stale stale bot closed this as completed Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests