简体   繁体   English

Python (googletrans) - AttributeError: 'NoneType' object 没有属性 'group'

[英]Python (googletrans) - AttributeError: 'NoneType' object has no attribute 'group'

Trying to detect language code in Python using googletrans .尝试使用googletrans检测 Python 中的语言代码。 But it generating ERROR (Refer error block for info).但它会产生错误(有关信息,请参阅错误块)。

Require solution for the same需要相同的解决方案

Code:代码:

import googletrans
from googletrans import Translator
translator = Translator()
result = translator.translate('Mitä sinä teet')
print(result.src)
print(result.dest)
print(result.origin)
print(result.text)
print(result.pronunciation)

Error:错误:


C:\ProgramData\Anaconda3\lib\site-packages\googletrans\gtoken.py in _update(self)
     60 
     61         # this will be the same as python code after stripping out a reserved word 'var'
---> 62         code = self.RE_TKK.search(r.text).group(1).replace('var ', '')
     63         # unescape special ascii characters such like a \x3d(=)
     64         code = code.encode().decode('unicode-escape')

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

This is a known, reported issue in the googletrans library's github page.这是googletrans库的 github 页面中报告的已知问题。 Take a look there to see the status of the fix and potential work arounds: https://github.com/ssut/py-googletrans/issues .在那里查看修复的状态和潜在的解决方法: https://github.com/ssut/py-googletrans/issues

According to the most recent comment, installing a different version, googletrans==4.0.0-rc1 , appears to work, but with caveats:根据最近的评论,安装不同的版本googletrans==4.0.0-rc1似乎可以工作,但有一些警告:

fire17 commented 16 days ago fire17 于16 天前发表评论
normal pip installation failed but uninstalled and reinstalled正常 pip 安装失败但卸载重装
googletrans==4.0.0-rc1 googletrans==4.0.0-rc1
then worked:)然后工作:)
tho the object is wierd, i can access the translated text like虽然 object 很奇怪,但我可以访问翻译后的文本,例如

a = translator.translate("hi") translated_text = a.__dict__()["text"]

It worked post re-installing googletrans它在重新安装 googletrans 后工作

pip install googletrans==4.0.0-rc1 pip 安装 googletrans==4.0.0-rc1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AttributeError: 'NoneType' object 在 googletrans 中没有属性 'group' - AttributeError: 'NoneType' object has no attribute 'group' in googletrans AttributeError: 'NoneType' object 没有属性 'group' googletrans python - AttributeError: 'NoneType' object has no attribute 'group' googletrans python AttributeError:“NoneType”对象在使用 googletrans 库时没有属性“组” - AttributeError: 'NoneType' object has no attribute 'group' while using googletrans library 我不明白为什么 python 中的 googletrans 不工作,它给出错误: AttributeError: 'NoneType' object has no attribute 'group' - I can't understand why googletrans in python isn't working, it gives error: AttributeError: 'NoneType' object has no attribute 'group' Googletrans API 错误 'NoneType' object 没有属性 '组' - Googletrans API Error 'NoneType' object has no attribute 'group' googletrans 停止工作并出现错误“NoneType” object 没有属性“group” - googletrans stopped working with error 'NoneType' object has no attribute 'group' AttributeError:'NoneType'对象没有属性'group'无法解析(Python) - AttributeError: 'NoneType' object has no attribute 'group' Can't Parse (Python) Python 正则表达式 AttributeError: 'NoneType' 对象没有属性 'group' - Python regex AttributeError: 'NoneType' object has no attribute 'group' Python 2.7 / Selenium 2 AttributeError:“ NoneType”对象没有属性“ group” - Python 2.7/Selenium 2 AttributeError: 'NoneType' object has no attribute 'group' Python GTTS 错误:AttributeError:'NoneType' 对象没有属性 'group' - Python GTTS Error : AttributeError: 'NoneType' object has no attribute 'group'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM