10

I'm having trouble using gTTS (Google Text to Speech) on my raspberry Pi 3. I simply did

sudo pip3 install gTTS

to install it. But when I run my code I find this error :


File "interface.py", line 7, in <module>

from gtts import *

File "/usr/local/lib/python3.4/dist-packages/gtts/\__init__.py", line 2, in <module>

from .tts import gTTS

File "/usr/local/lib/python3.4/dist-packages/gtts/tts.py", line 4, in <module>
 from requests.packages.urllib3.exceptions import InsecureRequestWarning

ImportError: cannot import name 'InsecureRequestWarning'

To try to solve the problem I did

sudo easy_install --upgrade pip

Then I have uninstalled and installed again gtts but the problem persists.

Thank you very much for your help ! :(

PS : I have installed python-vlc and mutagen to make working gTTS (as I did on a windows device)

sr_fpms_ig
  • 101
  • 1
  • 4

4 Answers4

7

Just update requests library

pip install -U requests
hspandher
  • 15,934
  • 2
  • 32
  • 45
  • Unfortunately this doesn't work. The `ImportError: cannot import name 'InsecureRequestWarning'` remains. – jengeb Jun 18 '17 at 12:24
1

Try this way.`

import urllib3`
urllib3.disable_warnings()

Though it doesn't remove the entire warning message, still removes the Insecure Request Warning

Vikram Sharma
  • 199
  • 2
  • 2
  • 13
  • After disabling the warnings the import error still remains: `ImportError: cannot import name 'InsecureRequestWarning'` – jengeb Jun 18 '17 at 12:27
1

Fixed it by running pip install requests==2.6.0

if you face issue with bringing request library to 2.6.0 first remove pyopenssl and then run pip install requests==2.6.0

MD5
  • 1,356
  • 15
  • 14
-1

I don't know if you still want to know but I can partially answer it.

import gtts

why this will work is because gtts automatically imports .tts and gTTS.

This is gtts.__init():

from .version import __version__
from .tts import gTTS

It's the only code in there.

You can go look yourself in the folder: /usr/local/lib/python3.4/dist-packages/gtts

OR

/usr/local/lib/python2.7/dist-packages/gtts

I am also trying to figure out still, how to use it but otherwise no.

CodinGuy
  • 33
  • 1
  • 5