简体   繁体   English

我正在使用 python3,我想翻译一些文本,所以我使用了“googletrans”package,但我收到了一些错误

[英]I am using python3 and I want to translate some text, So I used “googletrans” package, but I am getting some error

My Code:我的代码:

>> from googletrans import Translator translator = Transltor()
>> translator.translate("Hello",dest="hi") # "hi"  = in hindi language

But I am getting an error:但我收到一个错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "F:\YourTranslator\env\lib\site-packages\googletrans\client.py", line 182, in translate
    data = self._translate(text, dest, src, kwargs)
  File "F:\YourTranslator\env\lib\site-packages\googletrans\client.py", line 78, in _translate
    token = self.token_acquirer.do(text)
  File "F:\YourTranslator\env\lib\site-packages\googletrans\gtoken.py", line 194, in do
    self._update()
  File "F:\YourTranslator\env\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'

using python3, pip 2020 latest version Thanks In Advance使用 python3,pip 2020 最新版本提前致谢

Alright Guys, I found the answer好的伙计们,我找到了答案

first you have to uninstall your googletrans首先你必须卸载你的 googletrans

pip install googletrans

And then install this one:然后安装这个:

pip install googletrans==3.1.0a0

Error solved Found from here错误已解决这里找到

I dont know if it works for you, but using google_trans_new works for me.我不知道它是否适合您,但使用google_trans_new适合我。

to install:安装:

pip install google_trans_new

to use:使用:

from google_trans_new import google_translator
translator = google_translator()
mystring = "pick your language"
result = translator.translate(mystring, lang_tgt = "de")

暂无
暂无

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

相关问题 我已经在 python 2 中编写了一个代码,现在我想在 python3 中执行它,我收到错误 - I have written one code in python 2 now i want to execute this in python3, i am getting error 为什么我在使用 googletrans 时会收到 ModuleNotFoundError - Why am I getting a ModuleNotFoundError when using googletrans 我正在使用Python3,我想使用RabbitMQ - I am using Python3 and I want to use RabbitMQ 为什么我在 python3 中的这段代码会出现这个错误? - Why am i getting this error with this piece of code in python3? 为什么在我的python应用程序的某些行上出现额外的“ *”? - Why am I getting an additional “*” on some lines of my python app? 我在最近一次通话中遇到了一些错误 - I am getting some error in most recent call last 所以我正在尝试使用 atom 在我的 mac 上运行 python 脚本,但由于某种原因它无法正常工作 - So I am trying to run a python script on my mac using atom and for some reason it is not working right 我正在尝试使用 python 将 mp4 文件转换为文本,但出现此错误 - I am trying to convert mp4 file into text using python but i am getting this error 尝试解析一些json,但出现关键错误-Django - Trying to parse some json but i am getting a key error - Django 我想为某些功能制作gui,但它不像我想要的那样,我正在使用python 2.7和Tkinter? - i wanna make gui for some function but it's not like what i want i am using python 2.7 and it's Tkinter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM