import cv2
from fer import FER
Both imports do not work. They both fail with a similar error:
%Run testFer.py
Traceback (most recent call last):
File “N:\python\testFer.py”, line 1, in
import cv2
ModuleNotFoundError: No module named ‘cv2’
Please help.
where pip
and where python
to see where they are.
import sys
and print(sys.executable)
to see which one your IDE is using.
python -m pip
instead of pip
to use the pip that belongs to the active python.
I only installed Python yesterday - so i’m a noob but I got the latest version. This is what i just tried:
N:\python>where pip
C:\Users\61403\AppData\Local\Microsoft\WindowsApps\pip.exe
N:\python>where python
C:\Users\61403\AppData\Local\Microsoft\WindowsApps\python.exe
N:\python>import sys + print(sys.interpreter)
‘import’ is not recognized as an internal or external command,
operable program or batch file.
N:\python>python
Python 3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
">>> import sys + print(sys.interpreter)
File “”, line 1
import sys + print(sys.interpreter)
SyntaxError: invalid syntax
it doesn’t how the ^ but it points to the “+”
thanks
Sorry, these should go on separate lines in the python where you get the original problem with the ModuleNotFoundError:
import sys
print(sys.executable)
import cv2
Also try pip show opencv-python
to confirm it was installed.
">>> print(sys.interpreter)
Traceback (most recent call last):
File “stdin>”, line 1, in module>
AttributeError: module ‘sys’ has no attribute ‘interpreter’
">>> import cv2
">>> pip show opencv-python
File “stdin>”, line 1
pip show opencv-python
SyntaxError: invalid syntax (^^^ points to “show”)
">>> cv2
<module ‘cv2’ from ‘C:\Users\61403\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\cv2\init.py’>
My bad, I meant print(sys.executable)
.
pip show opencv-python
should go on the command line, not inside python.
It looks like cv2 can be imported now. So you either fixed it or did this in a different python than before.