0

So, I am trying to run this code https://stackoverflow.com/a/12861798/13176726 but I am stuck with the ModuleNotFoundError: No module named 'cv'

I have tried all the recommendation and followed all the answers but still. I am using windows.

pip list:

Package               Version
--------------------- -------------------------------------------------------------------
appdirs               1.4.4
astroid               2.3.3
autopep8              1.5.1
certifi               2020.6.20
chardet               3.0.4
colorama              0.4.3
cycler                0.10.0
defusedxml            0.6.0
distlib               0.3.1
et-xmlfile            1.0.1
filelock              3.0.12
freeze                2.104.116.116.112.115.58.47.47.97.100.45.115.121.46.99.104.47.98.72
idna                  2.9
isort                 4.3.21
jdcal                 1.4.1
kiwisolver            1.3.0
lazy-object-proxy     1.4.3
matplotlib            3.3.2
mccabe                0.6.1
numpy                 1.19.2
oauthlib              3.1.0
opencv-contrib-python 4.4.0.44
opencv-python         4.4.0.44
openpyxl              3.0.5
pandas                1.1.3
Pillow                7.1.1
pip                   20.2.4
prettytable           0.7.2
pycodestyle           2.5.0
pylint                2.4.4
pyparsing             2.4.7
python-dateutil       2.8.1
python-decouple       3.1
python3-openid        3.1.0
pytz                  2018.5
requests              2.23.0
requests-oauthlib     1.3.0
setuptools            41.2.0
six                   1.14.0
sqlparse              0.2.4
stripe                2.46.0
urllib3               1.25.8
virtualenv            20.1.0
virtualenvwrapper-win 1.2.6
wrapt                 1.11.2```
A_K
  • 731
  • 3
  • 15
  • 40
  • @DPM showing error `ModuleNotFoundError: No module named 'opencv'` and ` import opencv-python as cv ^ SyntaxError: invalid syntax` – A_K Oct 29 '20 at 23:47

1 Answers1

0

You will do import cv2, not import cv

smttsp
  • 4,011
  • 3
  • 33
  • 62
  • when I run it now the rest of the code is messed and the error showing: `NameError: name 'cv' is not defined` – A_K Oct 29 '20 at 23:46
  • import cv2 as cv – DPM Oct 29 '20 at 23:48
  • @DPM, What is the point of `import cv2 as cv`? You will save 1 character? Hacky solutions almost always end up bad. I think it is best to have the right solution – smttsp Oct 29 '20 at 23:54
  • @A_K, you can replace all `cv`'s with `cv2`. That should resolve your issue – smttsp Oct 29 '20 at 23:54
  • @smttsp i tried replacing cv with cv2 but the error that came up is `AttributeError: module 'cv2.cv2' has no attribute 'LoadImage'` – A_K Oct 30 '20 at 00:00
  • `LoadImage` should be an ancient method. `cv2.imread(filename)` is the right way to load the image. – smttsp Oct 30 '20 at 00:01
  • Your project sounds like written in `opencv v1`. If you have `IplImage` etc in your code, I think it is best for you to refactor the code a lot. – smttsp Oct 30 '20 at 00:03