So I was working on an AI voice assistant and I tried importing the speech_recognition module into my code but it didn't work.
I installed the module using:
pip install SpeechRecognition
It got installed correctly.
Then when I tried to import the module using:
import speech_recognition as sr
The name of the module wasn't auto suggested or highlighted while typing so I'm assuming the interpreter was unable to find the module.
And none of the functions I called got highlighted either and gave an error on execution. Any idea how I can fix this?
I think there is two ways of trying to solve this
1- Try Restarting your Editor
2- Try this:
python -m pip install SpeechRecognition
then restart the Editor.
Related
I am using a windows system and I have no idea why after I use the command "pip3 install pyautogui" it installs successfully however when I click the play button in VS code it gives me an error in the terminal -
ERROR
import pyautogui
ModuleNotFoundError: No module named 'pyautogui'
I am a pure beginner to Python so I have no idea what might be causing this issue. My code is below:
CODE
import pyautogui
screenWidth, screenHeight = pyautogui.size()
print(screenWidth)
print(screenHeight)
Any idea what I can do to solve this? I have checked similar questions but the answers were targeted more towards Linux users.
sometimes pip can have problems with certain libraries.
to get around this, you should download the .whl or tar.gz file and install it directly from there.
this is the .tar.gz file for pyautogui: https://files.pythonhosted.org/packages/f0/76/7a0ec1013bc3559b7438f6773cba05ffaec600b8989be2d621a144e39b50/PyAutoGUI-0.9.53.tar.gz
download it and put it in your project directory.
then, just pip install {THE FILE NAME}.
for me that fixed it.
I installed the speech recognition and the pyttsx3 libraries
pip install SpeechRecognition
pip install pyttsx3
but when i try to import them it gives two errors
Import "speech_recognition" could not be resolved
Import "pyttsx3" could not be resolved
heres my code
import speech_recognition as sr
import pyttsx3
audio = sr.Recognizer()
Usually this happens because of virtual env or interpreter issues. Possible fixes:
Make sure that the interpreter you are using inside your IDE, is the same as the one in which you installed the libraries.
Same as above in case of virtual env.
If your IDE is VS Code, then open the settings.json file and set python server to Jedi instead of Microsoft/Pylance.
I faced similar issues, was unable to diagnose the exact cause, but somehow the popular CodeRunner extension and VS code's recommended python extensions were in conflict. Therefore, i disabled the former and the program executed without any issues
i am a newbie in Python and want to try to tweet using python using this code, but after i run it, in python shell said that
from twython import Twython
ModuleNotFoundError: No module named 'twython'
Can someone help what's wrong with my code?
Welcome to Python family! When a module is first imported, Python searches for the module and if found, it creates a module object, initializing it. If the named module cannot be found, a ModuleNotFoundError is raised.
As a beginner, you should learn how to install a package in Python by going through the tutorial: https://packaging.python.org/tutorials/
Next, you should follow the installation guide in
https://twython.readthedocs.io/en/latest/usage/install.html
In the command prompt, you should run
pip install twython
Observe if any error pops up during the installation.
To see if Twython works correctly, start Python in the command prompt,
python
In the Python environment, run the following command:
>>> from twython import Twython
If Twython is installed correctly, you should not see the ModuleNotFoundError.
ModuleNotFoundError means that the module is not installed. Sometimes may be the module is installed but it is installed in a place where python does not look for it. In your case I feel you have not installed twython.
Open command prompt and type the following command
pip install twython
This should install the twython and after this if you run your file the error will not appear.
Check this out for more information on twython https://pypi.org/project/twython/
Firstly, you should try again pip install command,
Also:
If you are using an different place such as Pycharm or Jupyter or Anaconda, you must reinstall that module in that working environments
If you are using python's own ide, try add your current python path to system path
Re-read usage of your module
I am using powershell and scoop, windows.
I already installed speech_recognition bucket but still showing the error.
Code:
import speech_recognition as sr
import time
import json
import requests
import thread
import subprocess
SPLUNK_URL = "https://localhost"
# Splunk http event collector token
hec_token = ""
The python interpreter shows a ModuleNotFoundError when it can't find the module being imported. For more information on how import works, click here.
Since you have installed latest python 3.7, and are working on a code snippet that was built 2 years ago, there is likely a case that the speech_recognition module might not be installed for your current python.
Before you try anything, execute
pip list
and see all the modules currently installed for your current python interpreter. If the speech_recognition module is not available in the list, then install it:
pip install SpeechRecognition
Also, if you are having multiple python versions installed on your system then make sure you use the pip installer of the python interpreter that you are using for your application. If you are using or like having multiple python versions, then I suggest you use a tool like pyenv.
First I installed the coinmarketcap from the pycharm project interpreter.
Then I run the code below:
>>> from coinmarketcap import Market
>>> coinmarketcap = Market()
>>> coinmarketcap.ticker(<currency>, limit=3, convert='EUR')
But I got this:
ImportError: cannot import name Market
Then I thought it is not the right library, so I installed the following API from https://github.com/mrsmn/coinmarketcap-api thinking that pycharm might have installed some other library.
So I downloaded the library from Github and I used the python setup.py install command and installed the library from Github without any problems.
I tried to rerun the code, but the problem still persists:
ImportError: cannot import name Market
I have finally solved it. Actually I needed to uninstall it within pycharm. Then I installed it using the pip install coinmarketcap and after that it works.
Thank you for your help!
I have installed it using pip and tried to import it and did not get any error.so, can you check whether the installation is done with out any error