@ogw_jnch

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

googletrans

解決したいこと

以前動いていたgoogletransが動かなくなりました。
エラーメッセージの中にthis code will be updated when the format is changed とあります。
解決方法を教えてください。

発生している問題・エラー

コードを下記の簡単なものにしてもエラーがでます。
from googletrans import Translator
translator = Translator()
tx = translator.translate('Hello',src='en', dest='ja')

AttributeError                            Traceback (most recent call last)
<ipython-input-11-472e9c9c2b1d> in <module>
----> 1 tx = translator.translate('Hello',src='en', dest='ja')

~\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.

### 

例)

自分で試したこと

googletransをuninstallしてgoogletrans-tempをinstallしてみましたが変わりません。

1 likes

1Answer

Comments

  1. @ogw_jnch

    Questioner

    ありがとうございます。Anakonca promptとjupternotebookで入力してみましたが、Errorになってしまいました。 Jupiternotebookのエラーメッセージです。指定されたファイルが見つかりません。 while executing command git clone -q https://github.com/BoseCorp/py-googletrans.git C:\Users\mango\AppData\Local\Temp\pip-req-build-6wfbitvt
    Cannot find command 'git' - do you have 'git' installed and in your PATH?
    とあったので、
    !pip install GitPython
    を実行した後に再度実行しましたが、エラーメッセージは同じでした。
    何が悪いのでしょうか?
  2. gitが入ってないみたいです gitを導入してからコマンドを再度実行する必要があります
  3. @ogw_jnch

    Questioner

    ありがとうございます。 git をインストールしたら、pip install git+https://github.com/BoseCorp/py-googletrans.git --upgrade は成功しましたが、翻訳できません。


    Collecting git+https://github.com/BoseCorp/py-googletrans.git
    Cloning https://github.com/BoseCorp/py-googletrans.git to c:\users\mango\appdata\local\temp\pip-req-build-5ci7qcpf
    Requirement already satisfied, skipping upgrade: requests in c:\users\mango\anaconda3\lib\site-packages (from googletrans==2.3.0) (2.22.0)
    Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in c:\users\mango\anaconda3\lib\site-packages (from requests->googletrans==2.3.0) (2018.11.29)
    Requirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 in c:\users\mango\anaconda3\lib\site-packages (from requests->googletrans==2.3.0) (3.0.4)
    Requirement already satisfied, skipping upgrade: idna<2.9,>=2.5 in c:\users\mango\anaconda3\lib\site-packages (from requests->googletrans==2.3.0) (2.8)
    Requirement already satisfied, skipping upgrade: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\mango\anaconda3\lib\site-packages (from requests->googletrans==2.3.0) (1.24.1)
    Building wheels for collected packages: googletrans
    Running setup.py bdist_wheel for googletrans: started
    Running setup.py bdist_wheel for googletrans: finished with status 'done'
    Stored in directory: C:\Users\mango\AppData\Local\Temp\pip-ephem-wheel-cache-4q2xp_ct\wheels\6a\fc\9e\2d31d95d9e97da5166afd8225a6f3b6850dc2c6e84accefbfc
    Successfully built googletrans
    Installing collected packages: googletrans
    Found existing installation: googletrans 2.3.0
    Uninstalling googletrans-2.3.0:
    Successfully uninstalled googletrans-2.3.0
    Successfully installed googletrans-2.3.0

    簡単な
    from googletrans import Translator
    translator = Translator()

    tx = translator.translate('Hello',src='en', dest='ja')
    print(tx)
    の後のエラーメッセージです。

    AttributeError Traceback (most recent call last)
    <ipython-input-3-a4340201ebf1> in <module>
    2 translator = Translator()
    3
    ----> 4 tx = translator.translate('Hello',src='en', dest='ja')
    5 print(tx)

    ~\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.
  4. @ogw_jnch

    Questioner

    ありがとうございます。 なかなか難しくて、先に進めていません。もう少しいろいろ試してみます。

Your answer might help someone💌