ImportError: cannot import the name "InsecureRequestWarning" (PYTHON3 | RPI3 | gTTS)

I'm having trouble using gTTS (Google Text to Speech) on my Raspberry Pi 3. I just 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 solve the problem, I did

 sudo easy_install --upgrade pip 

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

Many thanks for your help!: (

PS: I installed python-vlc and mutagen to create working gTTS (as it was on a Windows device)

+5
source share
3 answers

Just update the requests library

 pip install -U requests 
+3
source

Try this way.

 import urllib3` urllib3.disable_warnings() 

Although it does not delete the entire warning message, it still removes the warning about the unsafe request

0
source

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

 import gtts 

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

This is gtts .__ init ():

 from .version import __version__ from .tts import gTTS 

This is the only code.

You can search for yourself in the folder: / usr / local / lib / python 3.4 / dist-packages / gtts

OR

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

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

-1
source

Source: https://habr.com/ru/post/1266930/


All Articles