Open Mohammadwh opened 4 years ago
The error @perymerdeka has posted always occur when attempting to perform bulk translation (trying to translate a list of strings).
This worked for me.
pip install googletrans==3.1.0a0
from googletrans import Translator
translator = Translator(service_urls=['translate.googleapis.com','translate.google.com','translate.google.co.kr'])
lang = translator.detect("who are you ?")
result = translator.translate("who are you ?", src='en', dest='hi')
print(lang)
print(result.text)
#Output -
Detected(lang=en, confidence=1.0)
तुम कौन हो ?
https://stackoverflow.com/a/65109346/9955390 https://github.com/ssut/py-googletrans/issues/234#issuecomment-748245530
The error @perymerdeka has posted always occur when attempting to perform bulk translation (trying to translate a list of strings).
in my case i translate string 10253 characters long in one request, its fail,but I try to split the string, it works, but sometimes the same error appears again, namely typeError
This worked for me.
pip install googletrans==3.1.0a0
from googletrans import Translator translator = Translator(service_urls=['translate.googleapis.com','translate.google.com','translate.google.co.kr']) lang = translator.detect("who are you ?") result = translator.translate("who are you ?", src='en', dest='hi') print(lang) print(result.text) #Output - Detected(lang=en, confidence=1.0) तुम कौन हो ?
many thannks. This works for me perfectly after suffering for a while.
from googletrans import Translator
translator = Translator() translated = translator.translate('Ina kake ne?. ko zaka bani abinci ne in ci?')
print(translated.text)
Where are you? Will you give me food to eat?
pip install googletrans==4.0.0-rc1
This worked for me.
Use this for google translation and it is working fine https://pypi.org/project/pygoogletranslation
Thank me later
Hi all, we find alternate library for googletrans, that is pygoogletranslation and its functionallity is same as the googletrans.
pip install by - pip install pygoogletranslation
For furthur information refer - https://pypi.org/project/pygoogletranslation/
https://saravananslb.github.io/py-googletranslation/
https://github.com/Saravananslb/py-googletranslation
Hi all, we find alternate library for googletrans, that is pygoogletranslation and its functionallity is same as the googletrans.
pip install by - pip install pygoogletranslation For furthur information refer - https://pypi.org/project/pygoogletranslation/ https://saravananslb.github.io/py-googletranslation/ https://github.com/Saravananslb/py-googletranslation
thank you
For me, googletrans still works fine, can someone compare the two to tell us what is the difference and which one is better? Julius
Just a brief glance: the one @Saravananslb published uses requests
as underlying web session library, while the original one we are using utilizes httpx
. The core token generation seems to be very similar, if not identical. I haven't checked clearly though, so take this comment with a grain of salt.
Just a brief glance: the one @Saravananslb published uses
requests
as underlying web session library, while the original one we are using utilizeshttpx
. The core token generation seems to be very similar, if not identical. I haven't checked clearly though, so take this comment with a grain of salt.
Yes, both are similar but googletrans support max 5000 character but pygoogletranslation support unlimited character.
Token generation process is similar but getting secret key is some what different for these two packages.
Pygoogletranslation support translation from file such as .doc, .docx, .pdf, .txt.
We are keep on updating our package to give end user a very flawless and good experience. We need to your support to improve our package and feedback are welcome.
For more information, please check our pygoogletranslation official python page or GitHub page.
Thanks, Saravananslb
Hi @ssut
pip install googletrans==4.0.0-rc1
Is still not working for me and gives the same old error:
AttributeError: 'NoneType' object has no attribute 'group'
There have been many proposed workarounds in this thread, but is there a official solution to this problem now?
Hi @ssut
pip install googletrans==4.0.0-rc1
Is still not working for me and gives the same old error:
AttributeError: 'NoneType' object has no attribute 'group'
There have been many proposed workarounds in this thread, but is there a official solution to this problem now? Yes, pip install by - pip install pygoogletranslation
For moreinformation refer - https://pypi.org/project/pygoogletranslation/ https://saravananslb.github.io/py-googletranslation/ https://github.com/Saravananslb/py-googletranslation
Hi @ssut
pip install googletrans==4.0.0-rc1
Is still not working for me and gives the same old error:AttributeError: 'NoneType' object has no attribute 'group'
There have been many proposed workarounds in this thread, but is there a official solution to this problem now? Yes, pip install by - pip install pygoogletranslationFor moreinformation refer - https://pypi.org/project/pygoogletranslation/ https://saravananslb.github.io/py-googletranslation/ https://github.com/Saravananslb/py-googletranslation
the pygoogletranslation library also throws several errors. I created an issue on their (your?) github. Thank you for referring. Let's try to keep this thread clean and focused on a solution for py-googletrans
:)
Hi @ssut
pip install googletrans==4.0.0-rc1
Is still not working for me and gives the same old error:AttributeError: 'NoneType' object has no attribute 'group'
There have been many proposed workarounds in this thread, but is there a official solution to this problem now? Yes, pip install by - pip install pygoogletranslationFor moreinformation refer - https://pypi.org/project/pygoogletranslation/ https://saravananslb.github.io/py-googletranslation/ https://github.com/Saravananslb/py-googletranslation
the pygoogletranslation library also throws several errors. I created an issue on their (your?) github. Thank you for referring. Let's try to keep this thread clean and focused on a solution for
py-googletrans
:)
Yes, sorry for the inconvenience caused. We have updated our package to v2.0.3. Please try this version, I hope we have sorted out all the errors. Let me know your feedback to improve our package. We have unlimited character support in the translation.
normal pip installation failed but uninstalled and reinstalled googletrans==4.0.0-rc1 then worked :) tho the object is wierd, i can access the translated text like
a = translator.translate("hi")
translated_text = a.__dict__()["text"]
So when I use googletrans==4.0.0-rc1 it doesn't error out however there is some weirdness:
>>>translator.detect('sentence written in english.')
<googletrans.models.Detected object at 0x7f8254228700>
>>>print(translator.detect('sentence written in english.'))
Detected(lang=en, confidence=None)
So the repr is not what is supposed to be per documentation and I think the issue is that it's not even defined in Detected class definition, fix for that would be to rename dunder str into repr, str just uses repr as a fallback so nothing else should change.
As for confidence, I tried using Translator.detect_legacy and for some reason it gives me confidence as expected.
>>>print(translator.detect_legacy('sentence written in english.'))
Detected(lang=en, confidence=1)
hello , same problem for me :(
Hello :
Traceback (most recent call last): File "/usr/local/bin/translate", line 40, in <module> main() File "/usr/local/bin/translate", line 21, in main result = translator.detect(args.text) File "/Library/Python/2.7/site-packages/googletrans/client.py", line 249, in detect data = self._translate(text, dest='en', src='auto') File "/Library/Python/2.7/site-packages/googletrans/client.py", line 75, in _translate token = self.token_acquirer.do(text) File "/Library/Python/2.7/site-packages/googletrans/gtoken.py", line 186, in do self._update() File "/Library/Python/2.7/site-packages/googletrans/gtoken.py", line 65, in _update code = unicode(self.RE_TKK.search(r.text).group(1)).replace('var ', '') AttributeError: 'NoneType' object has no attribute 'group'
Idea ? ;)
@SivaAndMe that work for me also https://github.com/SivaAndMe
I am getting this error too. Fix it please
I am getting this error too. Fix it please
Check #280
pip install googletrans==4.0.0-rc1
This worked for me.
It worked for me on detecting language. Thanks =]
@ssut pip install googletrans==4.0.0-rc1 worked perfectly for me. I'm using Python 3.9.1. mega thx ❤️ 💯
Still getting the JSON object must be str, bytes or bytearray, not NoneType
when passing a string greater than 5k and I have uninstalled / reinstalling googletrans==4.0.0rc1
Is this normal?? Has this specific issue been addressed in rc1?
This problem only occurs with googletrans==4.0.0rc1
It works fine on googletrans==3.1.0a0
I have tried googletrans==4.0.0-rc1 and googletrans==3.1.0a0 example: x = trans.translate("hello",dest="am") Error:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\UsersuserPycharmProjects\AndroidXMLTranslate\venv\lib\site-packages\googletrans-2.3.0-py3.8.egg\googletrans\client.py", line 172, in translate
data = self._translate(text, dest, src)
File "C:\UsersuserPycharmProjects\AndroidXMLTranslate\venv\lib\site-packages\googletrans-2.3.0-py3.8.egg\googletrans\client.py", line 75, in _translate
token = self.token_acquirer.do(text)
File "C:\UsersuserPycharmProjects\AndroidXMLTranslate\venv\lib\site-packages\googletrans-2.3.0-py3.8.egg\googletrans\gtoken.py", line 186, in do
self._update()
File "C:\UsersuserPycharmProjects\AndroidXMLTranslate\venv\lib\site-packages\googletrans-2.3.0-py3.8.egg\googletrans\gtoken.py", line 65, in _update
code = unicode(self.RE_TKK.search(r.text).group(1)).replace('var ', '')
AttributeError: 'NoneType' object has no attribute 'group'
googletrans == 4.0.0-rc1 is OK to me.
pip install google_trans_new
I have removed googletrans and replaced the state Cai now. It's working again
pip install googletrans==4.0.0rc1
This is pre-release. It's working for me.
Author, publish this pre-release as main.
Using Python 3.7 and googletrans==4.0.0rc1 worked like a charm for me! :D
This is still an issue. Use pip install googletrans==4.0.0rc1
and you will have no problems.
the issue is still present for bulk translations
I have the same issue Using python 3.7.6 and googletrans==4.0.0rc1
googletrans 3.0.0 which, at the time of writing, is the released version with Python 3.9.6, macOS 11.5, ISP is BT in the United Kingdom and the 'NoneType object has no attribute group...' issue is a problem for me.
It is obvious from the error trace that the problem lies in: RE_TKK.search(r.text) which is returning None.
Under what circumstances would it do that?
This problem occurs if you create a Translator instance for each use of the request. This problem can be partially avoided by using only one instance of the class.
Could you explain how to do that with an example please?
I met this issue also, and I fixed it by removing the param "service_urls" when constructing the "Translator()"
from
translator = Translator(service_urls=[
'translate.google.com',
'translate.google.com.hk',
'translate.google.co.kr',
])
to
translator = Translator()
hope this helps :)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\googletrans\gtoken.py", line 62, in _update code = self.RE_TKK.search(r.text).group(1).replace('var ', '') AttributeError: 'NoneType' object has no attribute 'group'
Author used regex for parse html :(
This problem occurs if you create a Translator instance for each use of the request. This problem can be partially avoided by using only one instance of the class.
Doesn't work for me even using only one instance.
What worked for me today was
pip uninstall googletrans==4.0.0-rc1
pip install googletrans==3.1.0a0
(solution from https://stackoverflow.com/a/69271089/7292383)
Translator()
service_urls
parameter, it workbest solution here: https://towardsdatascience.com/language-translation-using-python-bd8020772ccc
I fixed it with with changing the the service_urls with the non web version:
service_urls = ["translate.googleapis.com"]
translate.googleapis.com
this url was removed... returns 404
Python 3.12.2 (main, Feb 6 2024, 20:19:44) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin using googletrans==4.0.0rc1, works fine.
googletrans==4.0.0rc1, pythonwin 3.11.4 - works perfectly too
hi i use Python 3.6.9 and when i call translate have this error: