Pycharm/Python OpenCV and CV2 install error

前端 未结 16 1774
萌比男神i
萌比男神i 2020-12-24 00:23

I\'ve been trying to install both OpenCV and cv2 from both Pycharm and from the terminal as suggested using:

pip install --user opencv
pip install --user cv2         


        
16条回答
  •  余生分开走
    2020-12-24 00:39

    I ran into the same problem. One issue might be OpenCV is created for Python 2.7, not 3 (not all python 2.7 libraries will work in python 3 or greater). I also don't believe you can download OpenCV directly through PyCharm's package installer. I have found luck following the instructions: OpenCV Python. Specifically:

    1. Downloading and installing OpenCV from SourceForge
    2. Copying the cv2.pyd file from the download (opencv\build\python\2.7\x64) into Python's site-packages folder (something like: C:\Python27\Lib\site-packages)
    3. In PyCharm, open the python Console (Tools>Python Console) and type:import cv2, and assuming no errors print cv2.__version__

    Alternatively, I have had luck using this package opencv-python, which you can straightforwardly install using pip with pip install opencv-python

    Good luck!

提交回复
热议问题