1

If I run the following in a Jupyter notebook :

!pip install gTTS

from gtts import gTTS 

I get the following output:

Requirement already satisfied: gTTS in c:\users\username\.conda\envs\gpu\lib\site-packages (2.0.4)
Requirement already satisfied: click in c:\users\username\.conda\envs\gpu\lib\site-packages (from gTTS) (7.0)
Requirement already satisfied: six in c:\users\username\.conda\envs\gpu\lib\site-packages (from gTTS) (1.13.0)
Requirement already satisfied: gtts-token>=1.1.3 in c:\users\username\.conda\envs\gpu\lib\site-packages (from gTTS) (1.1.3)
Requirement already satisfied: requests in c:\users\username\.conda\envs\gpu\lib\site-packages (from gTTS) (2.22.0)
Requirement already satisfied: beautifulsoup4 in c:\users\username\.conda\envs\gpu\lib\site-packages (from gTTS) (4.8.1)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\username\.conda\envs\gpu\lib\site-packages (from requests->gTTS) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\username\.conda\envs\gpu\lib\site-packages (from requests->gTTS) (2019.11.28)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\username\.conda\envs\gpu\lib\site-packages (from requests->gTTS) (1.25.7)
Requirement already satisfied: idna<2.9,>=2.5 in c:\users\username\.conda\envs\gpu\lib\site-packages (from requests->gTTS) (2.8)
Requirement already satisfied: soupsieve>=1.2 in c:\users\username\.conda\envs\gpu\lib\site-packages (from beautifulsoup4->gTTS) (1.9.5)


ModuleNotFoundError: No module named 'gtts'

What should I do?

Edit: from gtts import gTTS works perfectly fine in the terminal.

Update:

TL;DR: Still facing this problem

Even after 5 months I haven't been able to narrow down what the problem is. The answers below are workarounds but don't actually address the main problem. Why is this happening? And jupyter notebook isn't the only tool where I am facing this issue. This is a similar question I asked titled "VSCode terminal doesn't activate conda environment". Similarly with Sublime text. I can't set up the internal console to build from environments.

  • 1
    can you confirm is it successfully installed? – Dishin H Goyani Dec 11 '19 at 07:36
  • from gtts import gTTS works perfectly fine in the terminal. – Sabito 錆兎 stands with Ukraine Dec 11 '19 at 08:05
  • For some packages, you need to restart the jupyter kernel after `!pip install` to use it. Also [autoreload](https://stackoverflow.com/questions/5364050/reloading-submodules-in-ipython) might help avoiding this. – Quang Hoang Dec 11 '19 at 08:07
  • I have always restarted the kernel. Even a complete reboot of the system doesn't work :( – Sabito 錆兎 stands with Ukraine Dec 11 '19 at 08:36
  • This problem is still haunting me. This time with `apiclient` from youtube API. Exact same issue. everything works fine on the terminal but can't import it in juptyer notebook!! – Sabito 錆兎 stands with Ukraine May 31 '20 at 14:09
  • I had this problem on MacOS, when installing jupyter with "brew install jupyter". had to uninstall and install it with "pip install jupyter". After this it works. Must be brew messing up the install with paths or something. Also something I noticed before is that if you do "pip install jupyter" at system level, and again in a pipenv, the system level jupyter will mess with the pipenv version by setting system paths, and appending its paths into the path before the pipenv installed ones. So just remove all jupyters and install in pipenv if this is case. – kg_sYy Mar 19 '21 at 13:11

2 Answers2

0

try:

!conda install gTTS
from gtts import gTTS 

Because you are using Conda, conda should be used instead of pip

CY_
  • 6,372
  • 1
  • 14
  • 24
0

pip install version to your default python version which is python2, you should do

!python3 -m pip install gTTS
from gtts import gTTs
Yash Shah
  • 100
  • 11