Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jrabensc opened this issue Apr 16, 2021 · 6 comments

Comments

@jrabensc
Copy link

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
@Kravcu
Copy link

Kravcu commented Apr 24, 2021

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.

@lonngxiang
Copy link

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

@Namyalg
Copy link

Namyalg commented Jul 31, 2021

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

@martinpmt
Copy link

martinpmt commented Aug 8, 2021

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

@Agan0525
Copy link

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

@Qu-Dasheng
Copy link

Qu-Dasheng commented Feb 20, 2022

  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


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants