【问题标题】:AttributeError: 'NoneType' object has no attribute 'group' while using googletrans libraryAttributeError:“NoneType”对象在使用 googletrans 库时没有属性“组”
【发布时间】:2022-06-30 16:35:57
【问题描述】:

以前一切正常,但现在当我尝试使用 googletrans 库时出错。这是我的代码

import googletrans    
from googletrans import Translator

translator = Translator()
df['data'] = df['tweet'].apply(lambda x: translator.translate(x, dest='en').text)
0 tweet
0 Heureusement que Macron n'a pas profité de la guerre en Ukraine pour être réélu mdr
1 L'Ukraine Ce pays formidable N'est-ce pas Macron le fou

【问题讨论】:

    标签: python


    【解决方案1】:

    您的代码对我来说可以正常工作。确保您拥有最新的 googletrans 版本或 4.0.0-rc1。

    在这里检查您的 googletrans 版本

    pip freeze
    

    在这里安装 googletrans 版本 4.0.0-rc1

    install googletrans==4.0.0-rc1
    

    【讨论】:

      猜你喜欢
      • 2022-01-15
      • 1970-01-01
      • 2019-02-26
      • 2022-11-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多