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"
Install the alpha version like this:
pip install googletrans==3.1.0a0
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
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
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
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
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
In the summer of 2008, after three decades of building software in corporate data centers, I walked away from corporate America to take a stab at building a technology company from the ground up based...
Cracking the Coding Interview PDF: 189 Programming Questions and Solutions, 6th Edition. I am not a recruiter. I am a software engineer. And as such, I know what it's like to be asked to create ing...
Become a master in Python by learning coding best practices and advanced programming concepts in Python 3.7. This book is written for Python developers who wish to go further in mastering Python. A...
A Practical Approach to Computer Algorithms Using Python® and C# Rod Stephens started out as a mathematician, but while studying at MIT, he discovered how much fun algorithms are. He took every al...