0

I am trying to build a Docker container in Raspbian 10.

FROM python:3.5-buster
RUN apt-get update
RUN apt-get install apt-utils -y
RUN apt-get install python-opencv -y
RUN apt-get install python3-opencv -y
COPY a.py /
CMD ["python3", "a.py"]

a.py is simply import cv2

When I run the container, I got the following errors.

Traceback (most recent call last):
  File "a.py", line 1, in <module>
    import cv2
ImportError: No module named 'cv2'
wannik
  • 101
  • 2
  • perhaps your python code might help? Also, this may have less to do with DevOps, than raspberry pi - have you tried posting in the rpi SO? – Bruce Becker Aug 07 '19 at 14:45
  • @BruceBecker My python code has one line: import cv2. I just posted in rpi as you suggested. – wannik Aug 08 '19 at 03:10

1 Answers1

1

Seems to be just an issue with a Python package.

Traceback (most recent call last):
  File "a.py", line 1, in <module>
    import cv2
ImportError: No module named 'cv2'

Is a common Python error, basically it can't find the package cv2.

You could try and install OpenCV through pip instead of installing through apt get. Something could be up with dependancies that you may have missed.

RUN pip3 install opencv-python