简体   繁体   中英

Can't import openCV in python 3

I use Anaconda 3, and try to installed the opencv by

pip install opencv_python-3.2.0.7-cp35-cp35m-win_amd64.whl

But it says(I had my userName erased):

Requirement already satisfied: opencv-python==3.2.0.7 from file:///C:/.../Download/opencv_python-3.2.0.7-cp35-cp35m-win_amd64.whl in c:\users\...\anaconda3\lib\site-packages Requirement already satisfied: numpy>=1.11.1 in c:\users\...\anaconda3\lib\site-packages (from opencv-python==3.2.0.7)

But I can't import cv2 at all, so I went to the site-packages folder, and found that there's no .py file called cv2, and in a folder called cv2, it's like that: 有线 So what's wrong with it? How am I supposed to fix it?

Have you tried pip install opencv-python ? So without the whl extension. Also, are you sure your Python is running on 64-bit?

Edit: I forgot the '-python' bit.

There are few solutions to your problem.

Follow this easiest one:

If you have installed Anaconda, go to Anaconda navigator (you can find navigator by searching in start menu).

Then go to the environments tab, in the main environment (Base(root)) select "not installed" and then in the search box type opencv and click on "apply". and Conda will install the latest version of opencv for you.

For calling the opencv in your code use:

import cv2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM