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)
Just update requests library
pip install -U requests
Try this way.`
import urllib3`
urllib3.disable_warnings()
Though it doesn't remove the entire warning message, still removes the Insecure Request Warning
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
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.
Related
Well, I've tried to run another's person telegram bot on my computer, but got a mistake that:
Traceback (most recent call last):
File "C:\Users\Dmitriy\PycharmProjects\pythonProject\Main.py", line 10, in <module>
keyboard = telebot.types.ReplyKeyboardMarkup(True, True)
AttributeError: module 'telebot' has no attribute 'types'
I've tried to import types from telebot:
from telebot import types
But it didn't actually helped. The strangest thing is that this code works on code owner's computer.
What can this be about?
enter image description here
The problem is that telebot and pyTelegramBotApi are different libraries but they are both imported via import telebot. In fact, when you do from telebot import types you import it from pyTelegramBotApi, not from telebot.
To fix the issue just type:
pip uninstall telebot
pip uninstall pyTelegramBotApi
pip install pyTelegramBotApi
It worked for me :)
You need to install python-telegram-bot f.e via pip
pip install python-telegram-bot
then import it from telegram package
from telegram import ReplyKeyboardMarkup
and replace creation of ReplyKeyboardMarkup into this:
keyboard = ReplyKeyboardMarkup(True, True)
for like these errors ... reinstall the library or use (--upgrade) when you install it !
like this:
pip uninstall telebot
pip install pyTelegramBotAPI
pip install pytelegrambotapi --upgrade
Happy Coding!
If you use PyCharm, then I advise you to do the following.
Go to the directory of your project.
In this directory, open the venv\Scripts directory (eventually you should get the following path \venv\Scripts)
Next, go to the command line along this path AND ONLY AFTER THAT WRITE the pip install pyTelegramBotAPI COMMAND ♥
Hi I thought this would be pretty straightforwards but I can't figure it out.
It can't find binance.websockets for whatever reason even though it can find binance.client which should be part of the same package?
import config
import os
from binance.client import Client
from twisted.internet import reactor
from binance.websockets import BinanceSocketManager
Running this import code gives this error
Traceback (most recent call last):
File "/home/lucho/Documents/cryptoAPIs/binance/importconfig.py", line 6, in <module>
from binance.websockets import BinanceSocketManager
ModuleNotFoundError: No module named 'binance.websockets
To get the library I installed with pip3
pip3 install python-binance
pip3 install binance-api
The BinanceSocketManager is no longer in the websockets file. Change your import to this:
from binance.streams import BinanceSocketManager
This will fix the issue
use this " pip install python-binance==0.7.9 "
If you look into the breaking changes on version 1.0.1 they mention they changes Websockets, so that is probably what you are hitting.
I would just reinstall the latest version "pip install python-binance" and use the up to date examples on their repo:
https://github.com/sammchardy/python-binance
I'm attempting to use the example code to receive data from Azure Event Hub.
Heres the code
import os
import sys
import logging
import time
from azure.eventhub import EventHubClient, Receiver, Offset
logger = logging.getLogger("azure")
ADDRESS = "amqps://mine.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=sadfsafdljksad=<eventhub>"
But I am getting the following error when executing..
Traceback (most recent call last):
File "./recv.py", line 5, in <module>
from azure.eventhub import EventHubClient, Receiver, Offset
ImportError: cannot import name 'EventHubClient'
Any assistance will be appreciated.
I think you actually installed azure-eventhub package, version 5.0.0. But EventHubClient does not exist in 5.0.0 version, it exists in azure-eventhub package, version 1.3.3 or below.
By default, when you install the azure eventhub package for python using this command pip install azure-eventhub, it will automatically install the latest version 5.0.0. So this sentence from azure.eventhub import EventHubClient, Receiver, Offset will throw the error ImportError: cannot import name 'EventHubClient'
You can check the version of the package by open cmd -> input command pip show azure-eventhub. Screenshot as below:
There are 2 solutions:
Solution 1: keep using the 5.0.0 version, then you should re-write your code and follow the examples in this doc.
Solution 2: If you want to use the current code which includes from azure.eventhub import EventHubClient, Receiver, Offset, you should first uninstall the 5.0.0 version of azure-eventhub, then reinstall the 1.3.3 version by using this command pip install azure-eventhub==1.3.3
Using this solution works fine
reinstall the 1.3.3 version by using this command pip install azure-eventhub==1.3.3
I am relatively new to Python and I am stuck on something which is probably relatively easy to resolve.
I have installed the following packages:
pip install --upgrade google-api-python-client
pip install --upgrade google-cloud
pip install --upgrade google-cloud-vision
In my Python file I have:
import cv2
import io
import os
# Imports the Google Cloud client library
from google.cloud import vision
...etc...
And this gives me the error:
Traceback (most recent call last):
File "test.py", line 6, in <module>
from google.cloud import vision
ImportError: No module named 'google.cloud'
What am I missing and where should I look (logs?) to find the answer in the future.
PS:
Pip installs of google-cloud and google-cloud-vision have the output:
Cannot remove entries from nonexistent file /Users/foobar/anaconda/lib/python3.5/site-packages/easy-install.pth
UPDATE:
Running pip freeze doesn't show the packages to be installed...
I had a similar problem. Adding "--ignore-installed" to my pip command made it work for me.
This might be a bug in pip - see this page for more details: https://github.com/pypa/pip/issues/2751
You need to download and install the google-cloud-sdk. Follow this link https://cloud.google.com/sdk/docs/
try this :
from google.cloud.vision import *
python noob here. Just start picking up python few weeks ago and currently need some help. I have 3.3.4 python for windows 7 and I tried running this:
import urllib.request
from googlevoice import Voice
from googlevoice.util import input
import time
File "<pyshell#0>", line 1, in <module>
from googlevoice import Voice
ImportError: No module named 'googlevoice'
so I figured. no big deal, I just need to install the module. I obtained a setup.py file from the link below and ran the file in different directories. Then tried " import googlevoice" but still doesn't work. The github link isn't too helpful, in terms of installing this module. Please help? I think I just have not learned how to install modules properly. Last time it took me a while to install pygame module, but i think it was because of directory issues at first.
https://pygooglevoice.googlecode.com/hg/
http://sphinxdoc.github.io/pygooglevoice/examples.html
To install the PyGoogleVoice, you need to download the whole archive and execute:
python setup.py install
If you have pip install, you can also run pip install pygooglevoice, or easy_install pygooglevoice with EasyInstall, without having to download the source code.