简体   繁体   中英

Import Error on PyCharm For cv2 and NumPy

I worked on a project on PyCharm a few years ago (which worked fine). However now when I run the first two lines of the program:

import cv2
import numpy as np

def getContours(img_orig):
    [Rest of Function]
.
.
.

I am getting the error:

Traceback (most recent call last):
  File "[PATH]", line 1, in <module>
    import cv2
ModuleNotFoundError: No module named 'cv2'

What is strange is the exact same code was working flawlessly a few years ago. I tried uninstalling and reinstalling the packages but there's no difference. What could be going on here?

You may be re-installing un-installing packages in a different enviorment then what pycharm is using for running it.

Try comparing pycharm's PYTHONPATH variable and pip --version 's output.

cv2 is generally provided by the opencv package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM