0

I'm using a separate environment called (tensorflow-sessions) and have opencv installed there through:

(tensorflow-sessions) $conda install -c menpo opencv

And in my normal path through:

pip install opencv-python

It works fine when I'm not in my environment, but not when I'm in it. Here's the error I get:

<ipython-input-13-78e172347b91> in <module>
----> 1 from imageai.Detection import VideoObjectDetection
      2 import os
      3 execution_path = os.getcwd()
      4 detector = VideoObjectDetection()
      5 #  SqueezeNet, ResNet, InceptionV3 and DenseNet.

~\Anaconda3\envs\tensorflow-sessions\imageai\Detection\__init__.py in <module>
----> 1 import cv2
      2 
      3 from imageai.Detection.keras_retinanet.models.resnet import resnet50_retinanet
      4 from imageai.Detection.keras_retinanet.utils.image import read_image_bgr, read_image_array, read_image_stream, preprocess_image, resize_image
      5 from imageai.Detection.keras_retinanet.utils.visualization import draw_box, draw_caption

~\Anaconda3\envs\tensorflow-sessions\cv2\__init__.py in <module>
      1 import importlib
      2 
----> 3 from .cv2 import *
      4 from .data import *
      5 

ModuleNotFoundError: No module named 'cv2.cv2'

What is causing this? Thanks in advance.

Atenean1
  • 82
  • 11
  • I believe this problem is also solved here: https://stackoverflow.com/questions/19876079/opencv-cannot-find-module-cv2 – Michael King Nov 30 '18 at 11:50

1 Answers1

0

It is possible the conda binary did not build correctly. Try installing from a different channel. The anaconda channel has a newer version than the menpo channel

conda uninstall opencv -n tensorflow-sessions
conda install opencv -n tensorflow-sessions -c anaconda
James
  • 32,991
  • 4
  • 47
  • 70