Pycharm/Python OpenCV and CV2 install error

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

    You are getting those errors because opencv and cv2 are not the python package names.

    These are both included as part of the opencv-python package available to install from pip.

    If you are using python 2 you can install with pip:

     pip install opencv-python
    

    Or use the equivilent for python 3:

    pip3 install opencv-python
    

    After running the appropriate pip command your package should be available to use from python.

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

    I rather use Virtualenv to install such packages rather than the entire system, saves time and effort rather than building from source.

    I use virtualenvwrapper

    Windows user can download

    pip install virtualenvwrapper-win
    

    https://pypi.org/project/virtualenvwrapper-win/

    Linux follow

    pip install opencv-python
    

    opencv-python

    If processing a video is required

    pip install opencv-contrib-python
    

    opencv-contrib-python

    If you do not need GUI in Opencv

    pip install opencv-contrib-python-headless
    

    opencv-contrib-python-headless

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

    here is a tutorial that worked for me without any problem.

    Copied from the site above the important part:

    Download the OpenCV version corresponding to your Python installation from here. In my case, I’ve used opencv_python-3.1.0-cp35-cp35m-win32.whl.

    Now, open a cmd window like before. You can open this directly in your Downloads folder if you SHIFT and right click inside it. The idea is to open a cmd window where you’ve downloaded the above [...] file. Use the [...] command to install [...] OpenCV:

    1     pip install "opencv_python-3.1.0-cp35-cp35m-win32.whl"
    

    Additional note: don't forget to change the name of the downloaded file in the command you use. Apparently by installing opencv, you'll have access to cv2 too.

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

    Installing opencv is not that direct. You need to pre-install some packages first.

    I would not recommend the unofficial package opencv-python. Does not work properly in macos and ubuntu (see this post). No idea about windows.

    There are many webs explaining how to install opencv and all required packages. For example this one.

    The problem of trying to install opencv several times is that you need to uninstall completely before attempting again, or you might end having many errors.

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