为什么选择"Googletrans.Translator"突然停止工作了? [英] Why "Googletrans.Translator" suddenly stopped working?

查看:386
本文介绍了为什么选择"Googletrans.Translator"突然停止工作了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几天前,我在Googletrans中使用Translator函数编写了几行内容.但是我今天试图重新运行这些行,但它弹出了一系列错误...我对此感到非常困惑.如果您遇到类似的问题,请在下面发表评论.欢迎任何帮助!

I wrote a few lines using Translator function in Googletrans a few days ago. But I was trying to re-run those lines today and it popped a series of errors... I'm really confused by this. If you have experienced similar issue, please comment below. Any help is welcome!!

from googletrans import Translator
translator = Translator()
trans1 = translator.translate('Hello', dest = 'es')

我得到的错误如下:

AttributeError                            Traceback (most recent call last)
<ipython-input-19-c0f9e5495a2f> in <module>()
----> 1 trans1 = translator.translate('Hello', dest = 'es')

~\AppData\Local\Continuum\anaconda3\lib\site-packages\googletrans\client.py in translate(self, text, dest, src)
    170 
    171         origin = text
--> 172         data = self._translate(text, dest, src)
    173 
    174         # this code will be updated when the format is changed.

~\AppData\Local\Continuum\anaconda3\lib\site-packages\googletrans\client.py in _translate(self, text, dest, src)
     73             text = text.decode('utf-8')
     74 
---> 75         token = self.token_acquirer.do(text)
     76         params = utils.build_params(query=text, src=src, dest=dest,
     77                                     token=token)

~\AppData\Local\Continuum\anaconda3\lib\site-packages\googletrans\gtoken.py in do(self, text)
    178 
    179     def do(self, text):
--> 180         self._update()
    181         tk = self.acquire(text)
    182         return tk

~\AppData\Local\Continuum\anaconda3\lib\site-packages\googletrans\gtoken.py in _update(self)
     57         r = self.session.get(self.host)
     58         # this will be the same as python code after stripping out a reserved word 'var'
---> 59         code = unicode(self.RE_TKK.search(r.text).group(1)).replace('var ', '')
     60         # unescape special ascii characters such like a \x3d(=)
     61         if PY3:  # pragma: no cover

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

我试图对此错误消息进行研究,但一无所获.最让我感到困惑的是,这个简单的代码在三天前就可以正常工作了.但是,当我今天早上开放时,我弹出错误.请帮忙.非常感谢!

I tried to do research on this error msg, but got nothing. What confused me the most is that this simple code worked perfectly fine 3 days ago. But when i open up this morning, i popped errors. Please help. Thank you so much!

推荐答案

我从解决方案:

pip install git+https://github.com/BoseCorp/py-googletrans.git --upgrade

对我来说效果很好!

这篇关于为什么选择"Googletrans.Translator"突然停止工作了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆