py-googletrans icon indicating copy to clipboard operation
py-googletrans copied to clipboard

when i run the demo code, raise a error as following:

Open shichg opened this issue 2 years ago • 3 comments
trafficstars

Traceback (most recent call last): File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevconsole.py", line 364, in runcode coro = func() ^^^^^^ File "", line 1, in File "/Users/mac/miniconda3/envs/Py311/lib/python3.11/site-packages/googletrans/client.py", line 194, in translate data, response = self._translate(text, dest, src) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/mac/miniconda3/envs/Py311/lib/python3.11/site-packages/googletrans/client.py", line 122, in _translate if r.status_code != 200 and self.raise_Exception: ^^^^^^^^^^^^^^^^^^^^ AttributeError: 'Translator' object has no attribute 'raise_Exception'. Did you mean: 'raise_exception'?

shichg avatar Aug 31 '23 06:08 shichg

it can be installed like this: pip install googletrans==4.0.0rc1

Use :

translator = Translator()
translation = translator.translate("سلام دوست عزیز", dest='en')
print(translation.text)
#output: 'Hello Dear Friend'

Link : https://github.com/ssut/py-googletrans/issues/234#issuecomment-742460612

Ref : https://stackoverflow.com/questions/52455774/googletrans-stopped-working-with-error-nonetype-object-has-no-attribute-group

amirroox avatar Aug 31 '23 18:08 amirroox

it can be installed like this: pip install googletrans==4.0.0rc1

Use :

translator = Translator()
translation = translator.translate("سلام دوست عزیز", dest='en')
print(translation.text)
#output: 'Hello Dear Friend'

Link : #234 (comment)

Ref : https://stackoverflow.com/questions/52455774/googletrans-stopped-working-with-error-nonetype-object-has-no-attribute-group

This issue doesn't fix the above issue. I'm also running 4.0.0rc1 and encountered the same issue. I imagine it's an easy fix to change the capitalisation but I would like the project I'm working onto be portable and changing it in each environment is too much.

pntha avatar Sep 08 '23 05:09 pntha

I uninstalled previous googletrans and installed using following command pip install googletrans==4.0.0rc1

after that it works for me.

For detailed explaination of problem refer https://stackoverflow.com/questions/52455774/googletrans-stopped-working-with-error-nonetype-object-has-no-attribute-group

PrashantDixit0 avatar Sep 08 '23 12:09 PrashantDixit0