Ask Your Question

dnn, python3.6, cv3.4.1 object_detection error

asked 2018-04-06 01:55:32 -0500

updated 2018-04-06 02:11:03 -0500

berak gravatar image
System information (version)
  • OpenCV => 3.4.1
  • Operating System / Platform => Windows 64 Bit
  • Python=>3.6
Detailed description

I have Opencv 3.4.1 installed using pipby downloading a wheel file from

pip install opencv_python-3.4.1-cp36-cp36m-win_amd64.whl

pip install opencv_python-3.4.1+contrib-cp36-cp36m-win_amd64.whl

When I print the the version of the cv2 inside the script I got 3.4.1, but I can't rund the code of object_detection because of the following errors:



Traceback (most recent call last):
File "", line 52, in <module>
net = cv.dnn.readNet(args.model, args.config, args.framework)
AttributeError: module 'cv2.dnn' has no attribute 'readNet'

I can solve this by replacing readNet with readNetFromCaffe while I use Caffe model . The moest weird thing is, when I go to the source of cv2/ I can't see the readNet() function!


Traceback (most recent call last):
File "", line 155, in <module>
if net.getLayer(0).outputNameToIndex('im_info') != -1:  # Faster-RCNN or R-FCN
AttributeError: 'cv2.dnn_Layer' object has no attribute 'outputNameToIndex'

But I couldn't fix this one!

Anyone an idea why I can't find readNet()? while I have the latest version of opencv.

I have also built Opencv3.4.1 from source on Ubuntu and I still can't find the readNet() function!

edit retag flag offensive close merge delete


you need the latest master branch for this, not the 3.4.1 release (this also means, you have to build from src, and can't rely on easy PIP install)

(yes, you can use readNetFromCaffe readNetFromTorch, etc, but other things, like certain layers might be still missing)

there is no cv2/ what do you mean ?

berak gravatar imageberak ( 2018-04-06 02:08:45 -0500 )edit

Thanks for your answer! You would expect when the wheel file contains 3.4.1 as a version number, that it has the latest version!

I built yesterday opencv 3.4.1 from source on Ubuntu 16.04, I still can't find readNet().

I am using pycharm as editor. This is what I mean, check screenshot

Peshmerge gravatar imagePeshmerge ( 2018-04-06 02:27:40 -0500 )edit

the PIP version numbers are frozen at the resp. opencv release (which is from febuary)

"I built yesterday opencv 3.4.1 from source" -- this might be the same problem.

berak gravatar imageberak ( 2018-04-06 02:29:19 -0500 )edit

It's unbelievable! I have just built it again from the source on Windows 10 using CMake, I still can't access readNet() !

Peshmerge gravatar imagePeshmerge ( 2018-04-06 05:56:16 -0500 )edit

maybe you should switch to git for downloading the src. (you'll also have to do that a few times in the future (bugfixes, updates), and you'd profit from incremental downloads)

berak gravatar imageberak ( 2018-04-06 06:03:04 -0500 )edit

What do you mean exactly? I have downloaded it from GitHub using this link

Peshmerge gravatar imagePeshmerge ( 2018-04-06 06:05:02 -0500 )edit

@Peshmerge, Perhaps you're looking for 3.4.1-dev that means a state of library after 3.4.1 but before the future release: If you want to use scripts compatible with 3.4.1 you can find them in downloaded source code.

dkurt gravatar imagedkurt ( 2018-04-07 05:59:04 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-04-09 01:31:52 -0500

Thanks, I have solved it by coning the master branch and building it from source!

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-04-06 01:55:32 -0500

Seen: 3,227 times

Last updated: Apr 09 '18