ImportError: No module named 'cv2' Python3

前端 未结 6 1773
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-31 05:30

I have such a problem

(face_det) user@pc:~$ python3
Python 3.5.3 (default, Apr 22 2017, 00:00:00) 
[GCC 4.8.4] on linux
Type \"help\", \"copyright\", \"credi         


        
相关标签:
6条回答
  • 2020-12-31 05:33

    Your conda openCV is installed for use by your home python2.7. Your opencv installed via pip3 is for use in your face_det virtual environment. It doesn't look like you're in that virtual environment when you opened python3 in the first code block. Try

    source activate face_det
    python3
    import cv2
    
    0 讨论(0)
  • 2020-12-31 05:44

    My problem was trying to use opencv version 4.2.x on macOS Catalina. Turns out they are not compatible. What i initially used was:

    pip3 install opencv-python
    

    Which gives you the newest version. So i installed a previous version with this and solved my problem:

    pip3 install opencv-python==4.1.1.26
    

    If you type:

    pip3 install opencv-python==10.99.100
    

    For example, that version does not exist so it will give you a list of all available versions so you can choose.

    Tried on:

    • Catalina 10.15.4
    • Python 3.5.9

    Edit: I also had to downgrade from python 3.7 to 3.5.9 in order for it to work.

    0 讨论(0)
  • 2020-12-31 05:48

    Try

    pip3 install opencv-python
    

    to get the cv2. I'm not sure when opencv-python became available. I'd been building opencv by hand, but when I looked a few weeks ago, there it was. I'm using cv2 with Python3 in a VM that's running ubuntu/trusty64.

    0 讨论(0)
  • 2020-12-31 05:49

    Try

    sudo python3.5 -m pip install opencv-python
    

    It worked for me

    0 讨论(0)
  • 2020-12-31 05:52

    I had a similar problem and the same error. In my case, I was using PyCharm. The problem was that the project's interpreter was pointing to a different installation of Python.

    In my system, I had four versions of python (eg. python3 installed in a python36 folder, another python in an anaconda3 folder and others). In my PyCharm project, when I examined my settings (under File->Settings->Project:xxxx ->Project interpreter), I found that they were pointing to the interpreter in the anaconda3 folder.

    However, my default pip installed the opencv-python module under the python36 folder. Therefore, I just had to change the project interpreter to point to the python installed in python36 folder and it worked.

    If you would like to keep using Anaconda3 then you have to browse to the anaconda3 folder and run pip install opencv-pithon in that folder.

    0 讨论(0)
  • 2020-12-31 05:55

    I think you're on Linux judging by pc:~$

    Try installing from the following link:

    http://docs.opencv.org/3.0-beta/doc/tutorials/introduction/linux_install/linux_install.html

    It worked for me, hope the same for you!

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