import cv2 >> ModuleNotFoundError: No module named 'cv2' - python

import cv2
ModuleNotFoundError: No module named 'cv2'
although it already installed but run in cmd only
not working in any IDE like Vs or spyder or Jupyter
i wanna to make IDE import OpenCv

try:
import opencv-python
except:
subprocess.check_call([sys.executable, "-m", "pip", "install", 'opencv-python'])
Alternatively, open a console in your IDE and execute the following:
pip install opencv-python
Your IDE probably uses a different python instance to the one your console uses

Related

Interpreter with installed 'matplotlib': ModuleNotFoundError: No module named 'matplotlib'

I use JetBrains DataSpell for Jupyter. I use conda interpreter (Python 3.10) and I have installed matplotlib, but when I run this code:
import matplotlib.pyplot as plt
I got this error:
ModuleNotFoundError: No module named 'matplotlib'
The strangest thing is that when I start writing "import matpl..." my kernel prompts me "matplotlib" and see class "pyplot" also. So my kernel sees this library while writing code...
I got installed matplotlib 3.5.2 version
installed package

I have installed keyboard, but it wont import

I did:
pip install keyboard
It shows up in my file directory, however when I try and import it I get the following message:
ModuleNotFoundError: No module named 'keyboard'
I am using Python 3.10, and keyboard 0.13.5.
Any suggestions would be greatly apreciated.

Can't import pyinputplus module

When I try to import the module on Mu, I get the error: ModuleNotFoundError: No module named 'pyinputplus'
However, on command prompt it says its successfully installed. Im on windows 10 and using python 3.9. any help appreciated
First, you have to install that module in your computer.
By using:
pip install pyinputplus
Then, you can import it by:
import pyinputplus as pyip
and then, you will get results like this.

Module not found, even when I have installed it

I'm trying to use the PyAutoGUI lib, and I get this error ModuleNotFoundError: No module named 'Xlib'. I have already tried sudo apt-get install python-xlib, pip3 install xlib and all the instalation commands that i have found, but no result.
This is the error I get
File "/root/.../_pyautogui_x11.py", line 7, in <module>
from Xlib.display import Display
ModuleNotFoundError: No module named 'Xlib'
Solution:
What I did finally is install the xlib library from PyCharm, and it worked.
Confirm xlib was actually installed in this folder
Python/Lib/site-packages
If it was installed, make sure the name you're importing is typed exactly as the name of the xlib folder/module. For example: if the folder is named xlib, you import this way;
from xlib.display import Display
NOT this way
from Xlib.display import Display

Why am i getting ModuleNotFoundError: No module named 'scipy'?

I wrote the following python line import scipy.io then I went to that folder's location in the cmd:
C:\Users\me\PycharmProjects\test>
and typed pip install scipy apparently it installed the dependencies then I went back to pycharm, ran my code and got error
ModuleNotFoundError: No module named 'scipy'
I'm just starting off with python I'm on windows 10.
PyCharm has a GUI for managing which python installation you use and packages installed:
https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html

Categories