Poul K. Sørensen
Poul K. Sørensen

Reputation: 17540

How to get OpenCV to detect python installed with conda in docker

I have composed a docker file from a few sources, but keep running into the problem that when building opencv, it will not find python.

I added the dockerfile to https://gist.github.com/pksorensen/e06a783c31d4e95e60f1376baa8d562e as the post start to hit limit.

The problem shows at the end when cv2 is not avaible from python

chainer@cbd2c9c51a21:/src/image-labelling-tool/examples/ssd$ python
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'cv2'
>>>

I come to the conclusion that its due to the use of conda and opencv from two docker files and I am guessing :) Much appreciated if anyone can share some light on what i am doing wrong?

Output from cmake step is here https://gist.github.com/pksorensen/e06a783c31d4e95e60f1376baa8d562e#file-out-txt

Upvotes: 0

Views: 282

Answers (1)

Poul K. S&#248;rensen
Poul K. S&#248;rensen

Reputation: 17540

using PYTHON3 variables solved it.

-D PYTHON3_LIBRARY=$CONDA_DIR/lib/python3.5 \
-D PYTHON3_INCLUDE_DIRS=$CONDA_DIR/include/python3.5m \
-D PYTHON3_EXECUTABLE=$CONDA_DIR/bin/python3 \
-D PYTHON3_PACKAGES_PATH=$CONDA_DIR/lib/python3.5/site-packages \

--   Python 3:
--     Interpreter:                 /opt/conda/bin/python3 (ver 3.6.2)
--     Libraries:                   /opt/conda/lib/python3.5 (ver 3.6.2)
--     numpy:                       /opt/conda/lib/python3.6/site-packages/numpy/core/include (ver 1.13.1)
--     packages path:               /opt/conda/lib/python3.5/site-packages

Upvotes: 1

Related Questions