Pycharm/Python OpenCV and CV2 install error

前端 未结 16 1639
萌比男神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
    python3.6 -m pip install opencv-python
    

    will install cv2 in python3.6 branch

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

    When I was facing this issue I used to install OpenCV in pycharm installed package panel where we can find under the settings tab. Search "OpenCV-python" and install it in the installed package panel of right interpreter.

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

    you must install opencv-python pip/pip3 install opencv-python if you try import opencv-python, receive error. Fix this error, use the import cv2

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

    Try this. I am using Jupyter notebook (OS: Ubuntu 16.04 LTS on Google Cloud Platform + on Windows). Executed following command in the Jupyter notebook to install opencv:

    !pip install opencv-contrib-python    #working on both Windows and Ubuntu
    

    After successful installation you will get following message:

    Successfully installed opencv-contrib-python-4.1.0.25
    

    Now restart the kernel and try to import opencv as:

    import cv2
    

    The same command can be used to installed opencv on Windows as well.

    SOLUTION 2: try following commands to install opencv: For Ubuntu: Run following command from terminal:

    sudo apt-get install libsm6 libxrender1 libfontconfig1
    

    Restart Jupyter notebook kernel and execute following command:

    !pip install opencv-contrib-python
    

    NOTE: You can run all the above commands from the terminal as well without using '!'.

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

    In jetso nano this work for me.

    $ git clone https://github.com/JetsonHacksNano/buildOpenCV
    $ cd buildOpenCV
    
    0 讨论(0)
  • 2020-12-24 00:46

    I had the same problem. Here are the steps for Windows 10 users.

    Open CMD: win+r then type cmd. Now,

    1. Type pip install virtualenv
    2. Create a Virtual Environment, Type virtualenv testopencv
    3. Get Inside testopencv, Type cd testopencv
    4. Activate the Virtual Environment, Type .\Scripts\activate
    5. Now Install Opencv, Type pip install opencv-contrib-python --upgrade
    6. Let's test Opencv, Type Python then import cv2 hit enter then type print(cv2.__version__) to check if its installed

    Now, open a new cmd, win + r then type cmd, repeat step 6. If it gives you an error.

    Go inside the testopencv folder, inside lib. Copy everything, go to your python directory, inside lib folder paste it and skip that are already present.

    Again open a new cmd, repeat Step 6.

    Hope it helps.

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