Pycharm/Python OpenCV and CV2 install error

前端 未结 16 1650
萌比男神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:30

    This the correct command that you need to install opencv

    pip install opencv-python
    

    if you get any error when you are trying to install the "opencv-python" package in pycharm, make sure that you have added your python path to 'System Variables' section of Environment variables in Windows. And also check whether you have configured a valid interpreter for your project

    0 讨论(0)
  • 2020-12-24 00:31

    In win, download the py based latest numpy and Opencv from Unofficial Windows Binaries for Python Extension Packages and pip install its source in cmd. Later copy site-package folder from main py lib to venv lib.

    0 讨论(0)
  • 2020-12-24 00:32

    this will help you

    pip3 install opencv-python
    

    this is the snippet of successful installation

    0 讨论(0)
  • 2020-12-24 00:34

    How about try some different mirrors? If you are in China, I highly recommend you try:

    sudo pip install --index https://pypi.mirrors.ustc.edu.cn/simple/ opencv-contrib-python
    

    If not, just replace the url address to some other mirrors you like! Good luck.

    0 讨论(0)
  • 2020-12-24 00:36

    On Windows : !pip install opencv-python

    0 讨论(0)
  • 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!

    0 讨论(0)
提交回复
热议问题