ModuleNotFoundError: No module named 'googletrans' although I installed it correctly

Viewed 1343

I'm trying to import a googletrans package but I got a ModuleNotFoundError when I'm trying to import it although I installed it.

I got this error

11 #to translate the text data
12 get_ipython().system('pip install googletrans')
---> 13 from googletrans import Translator

ModuleNotFoundError: No module named 'googletrans'

I'm trying to install a googletrans package with all possible syntax on jupyter notebook

!pip install googletrans
!pip install googletrans==4.0.0-rc1 #to avoid 'NoneType' object has no attribute 'group' error
!pip install googletrans==3.1.0a0 #to avoid 'NoneType' object has no attribute 'group' error

after I'm installing it, I'm trying to import it

from googletrans import Translator

I got this error

11 #to translate the text data
12 get_ipython().system('pip install googletrans')
13 from googletrans import Translator

ModuleNotFoundError: No module named 'googletrans'

ModuleNotFoundError: No module named 'googletrans'

but I have to notify you that the output from pip command is

Collecting googletrans
  Using cached googletrans-3.0.0-py3-none-any.whl
Collecting httpx==0.13.3
  Using cached httpx-0.13.3-py3-none-any.whl (55 kB)
Requirement already satisfied: certifi in c:\programdata\anaconda3\envs\python310\lib\site-packages (from httpx==0.13.3->googletrans) (2021.10.8)
Collecting hstspreload
  Using cached hstspreload-2021.12.1-py3-none-any.whl (1.3 MB)
Requirement already satisfied: sniffio in c:\programdata\anaconda3\envs\python310\lib\site-packages (from httpx==0.13.3->googletrans) (1.2.0)
Requirement already satisfied: rfc3986<2,>=1.3 in c:\programdata\anaconda3\envs\python310\lib\site-packages (from httpx==0.13.3->googletrans) (1.5.0)
Requirement already satisfied: chardet==3.* in c:\programdata\anaconda3\envs\python310\lib\site-packages (from httpx==0.13.3->googletrans) (3.0.4)
Collecting httpcore==0.9.*
  Using cached httpcore-0.9.1-py3-none-any.whl (42 kB)
Collecting idna==2.*
  Using cached idna-2.10-py2.py3-none-any.whl (58 kB)
Collecting h2==3.*
  Using cached h2-3.2.0-py2.py3-none-any.whl (65 kB)
Requirement already satisfied: h11<0.10,>=0.8 in c:\programdata\anaconda3\envs\python310\lib\site-packages (from httpcore==0.9.*->httpx==0.13.3->googletrans) (0.9.0)
Requirement already satisfied: hpack<4,>=3.0 in c:\programdata\anaconda3\envs\python310\lib\site-packages (from h2==3.*->httpcore==0.9.*->httpx==0.13.3->googletrans) (3.0.0)
Requirement already satisfied: hyperframe<6,>=5.2.0 in c:\programdata\anaconda3\envs\python310\lib\site-packages (from h2==3.*->httpcore==0.9.*->httpx==0.13.3->googletrans) (5.2.0)
Installing collected packages: idna, hstspreload, h2, httpcore, httpx, googletrans
  Attempting uninstall: idna
    Found existing installation: idna 3.3
    Uninstalling idna-3.3:
Output exceeds the size limit. Open the full output data in a text editor
WARNING: Ignoring invalid distribution -na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -2na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -1na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -0na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -dna (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -2na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -1na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -0na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -dna (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -2na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -1na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -0na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -dna (c:\programdata\anaconda3\envs\python310\lib\site-packages)
    WARNING: Ignoring invalid distribution -na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
    WARNING: Ignoring invalid distribution -2na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
    WARNING: Ignoring invalid distribution -1na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
    WARNING: Ignoring invalid distribution -na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
...
WARNING: Ignoring invalid distribution -na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -0na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -dna (c:\programdata\anaconda3\envs\python310\lib\site-packages

It's installed with these warnings.

What's the wrong here? is it with the installation or with the import syntax and how I can solve it.

note: I'm using anaconda with 3.9.7 and 3.10

2 Answers

I see in your logs that you are using Anaconda. To install this package with conda run one of the following:

conda install -c conda-forge googletrans

conda install -c conda-forge/label/cf201901 googletrans

conda install -c conda-forge/label/cf202003 googletrans
Related