Saravananslb/py-googletranslation

ImportError: cannot import name 'TranslatedPart' from 'googletrans.models'

jrabensc opened this issue ยท 6 comments

Describe the bug
Import error when package is imported: Import Error: cannot import name 'TranslatedPart' from 'googletrans.models'

To Reproduce
Install and import pygoogletranslation

!pip install pygoogletranslation
import pygoogletranslation
ModuleNotFoundError: No module named 'googletrans'

Package googletrans seems to be missing.

Install googletrans

!pip install googletrans
import pygoogletranslation
ImportError: cannot import name 'TranslatedPart' from 'googletrans.models' (/usr/local/lib/python3.7/dist-packages/googletrans/models.py)

Expected behavior
No import error

Desktop (please complete the following information):

  • Happens both on Google Colab and local Arch Linux installation
  • Python 3.7.10 (Google Colab), Python 3.9.2 (local), pygoogletranslation 2.0.6

I have the same issue in environment:

  • Python 3.8.7
  • pygoogletranslation 2.0.6
  • Windows 10 x64

This seems to be an issue with version 2.0.6 as version 2.0.5 works correctly on my platform.

ImportError: cannot import name 'TranslatedPart' from 'googletrans.models'

I am facing the same issue, unable to import the package

try to install googletrans 4.0.0-rc1, because in this version there found TranslatedPart class on models.py

pip install googletrans==4.0.0-rc1

it works on my environment
-pygoogletranslation 2.0.6
-Python 3.8.5
-Windows 10 x64

faced the same issue and had solved it.
the error info :
ImportError: cannot import name 'TranslatedPart' from 'googletrans.models'

try to change the package code in **\Lib\site-packages\pygoogletranslation\translate.py line 19
before:
from googletrans.models import Translated, Detected

changed:
from pygoogletranslation.models import Translated, Detected

  1. cd the following path

YOUR PYTHON INSTALL PATH /lib/site-packages/pygoogletranslation/utils.py


  1. comment the code

from googletrans.models import TranslatedPart #about 8th line


  1. write new import

from pygoogletranslation.models import TranslatedPart