This question already has answers here:
Cannot find module cv2 when using OpenCV
(24 answers)
Closed 5 years ago.
I need to execute a Python application, but I am getting this error:
Traceback (most recent call last): File "dataset.py", line 8, in import cv2 ImportError: No module named cv2
I have followed the face detection concept in 96 boards, but I keep getting above error message, when I run the script like this:
sudo python dataset.py
Have you installed openCV?
sudo apt-get install python-opencv
If you want install it with pip:
pip install opencv
Related
This question already has answers here:
Python program works only from pycharm, not somewhere else
(3 answers)
Closed 10 months ago.
To use the pillow module I wrote down the command:
pip install pillow
And in the file to use I wrote:
from PIL import Image
But I get the error:
ModuleNotFoundError: No module named 'PIL'
what can I do?
Install pillow by writing pip install Pillow in your terminal. (P in Pillow is capitalised )
Then you can call the image library using: from PIL import Image (PIL in all capital and Image is capitalised)
This question already has answers here:
How to install and import Python modules at runtime
(5 answers)
Closed 1 year ago.
I am trying to install and import this python module in the same file. I am adding the directory where I want networkX to be installed in PYTHONUSERBASE, and I even prepend it to the PATH.
#install and import networkx
os.environ['PYTHONUSERBASE'] = "some_other_directory/python_packages"
executeCommand('python3 -m pip install --user networkx[default]')
sys.path.insert(0, os.environ['PYTHONUSERBASE'])
importlib.invalidate_caches()
import networkx
However, I get this error:
Traceback (most recent call last):
File "file_that_runs_the_code.py", line 35, in <module>
import networkx
ModuleNotFoundError: No module named 'networkx'
Any help would be appreciated.
The answer posted by #Tom McLean did solve the issue, but I would like to point out the following:
The answer provided might throw errors for pip 10 or higher. If your version of pip is higher than 10, I recommend replacing
pip.main(['install', package])
with
os.system('pip install ' + package)
For more information on the errors that might be thrown if you are using pip10+, check out this link: https://github.com/pypa/pip/issues/5599
This question already has answers here:
No Module Named ServerSocket
(5 answers)
Closed 3 years ago.
Traceback (most recent call last):
File "server.py", line 1, in <module>
import SocketServer
ModuleNotFoundError: No module named 'SocketServer'\
The Error is because you did not install the package.
Install the package, before importing them
For Python command prompt,
pip install package_name
pip install httpserver
For Anaconda Navigator prompt,
conda install package_name
When Importing Socketsever, all in small letters (Package got renamed in python3)
import socketserver
This question already has answers here:
ImportError: No module named scipy
(17 answers)
Closed 3 years ago.
I am setting up a speech recognition software using mozilla and want to use the pre-trained model.
This is for macosx, I have already installed pip and the related scipy file however my system cant seem to pull the scipy module when I run my python script. Could it be that this is installed in another directory from the virtual env itself?
Terminal
(deepspeech-venv) Chabanis-MacBook-Pro:deepspeech chabani$ pip3 list
Package Version
---------- -------
deepspeech 0.5.1
numpy 1.17.0
pip 19.2.1
scipy 1.3.1
setuptools 41.0.1
wheel 0.33.4
Python
import scipy.io.wavfile as wav // this is the issue here
Terminal - deepspeech path
(deepspeech-venv) Chabanis-MacBook-Pro:deepspeech chabani$ which deepspeech
/Users/chabani/tmp/deepspeech-venv/bin/deepspeech
=== RESTART: /Users/chabani/tmp/deepspeech-venv/lib/python3.7/activate.py ===
Traceback (most recent call last):
File "/Users/chabani/tmp/deepspeech-venv/lib/python3.7/activate.py", line 7, in <module>
import scipy.io.wavfile as wav
ModuleNotFoundError: No module named 'scipy'
try to run this command:
pip3 install scipy
This is my first question so apologies about format etc.
I'm trying to do the python exercise on http://newcoder.io/dataviz/part-0/ and I'm attempting to install the pre-requisites for working within a virtualenv.
At the stage
(DataVizProj)$ pip install numpy
(DataVizProj)$ pip install matplotlib
It seems to install fine. However on testing matplotlib within python itself (running a python terminal and then trying "import matplotlib") I am getting the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named matplotlib
I have also tried sudo apt-get build-dep matplotlib but every time I am getting the above error. I have googled to no avail - can anybody assist?
P.s. I am using Ubuntu