# How to import OpenCV in Python3?

Source: https://forum.modalai.com/topic/64/how-to-import-opencv-in-python3
Category: VOXL SDK and Software (https://forum.modalai.com/category/47/voxl-sdk-and-software)
Posted: 2020-12-22 06:20:09 UTC by Alex123
Replies: 10 · Views: 3603

## Alex123 · 2020-12-22 06:20:09 UTC

I've installed Python3 on the voxl core-board. I've also installed OpenCV-3.4.6 using https://gitlab.com/voxl-public/other/voxl-opencv-3-4-6
But I'm unable to access OpenCV in Python3.
I'm getting an error like this.
 
/ # python3
Python 3.6.9 (default, Dec 19 2020, 12:09:26)
[GCC 4.9.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
**>>>import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'**

**How to import OpenCV in Python3?**

Any suggestions would be greatly appreciated!
Thanks!

## Reply by modaltb (ModalAI staff) · 2020-12-24 18:22:50 UTC

Hi @Alex123 , 

The opencv-3-4-6 project above isn't a python3 package  installation rather for c++, for example:

https://gitlab.com/voxl-public/other/voxl-opencv-3-4-6/-/blob/master/examples/april-tag-detect/april-tag-detect.cpp

Are you requirements Python3.6.9 and OpenCV 3.X? (let me know specifics if possible).

If so, do you requirements allow you to run your program in a Docker container on VOXL?

Thanks!

## Reply by Alex123 · 2020-12-29 06:23:17 UTC

Yes, I have to run my program using Python3.6.9  and OpenCV 4.X.
And it wouldn't allow running a program on Docker container on VOXL.

## Reply by Chad Sweet (ModalAI staff) · 2020-12-29 06:56:36 UTC

The easiest path is to use an Ubuntu Docker container on VOXL. https://docs.modalai.com/docker-on-voxl/

Otherwise you will have to build the python bindings for OpenCV. We have never tried this, but it looks well documented here: https://docs.opencv.org/master/da/d49/tutorial_py_bindings_basics.html

## Reply by Alex123 · 2020-12-29 10:29:54 UTC

@Chad-Sweet 
If I'll use an Ubuntu Docker container on VOXL, can you provide documentation or steps using which I can build OpenCV4.x on Python 3.6.9?

Or a pre-build file of OpenCV4.x for Python3.6.9?

Thanks!

## Reply by Alex123 · 2020-12-31 12:17:43 UTC

How can I use OpenCV4.x with Python3.6.9 using Ubuntu Docker container on VOXL?

## Reply by Chad Sweet (ModalAI staff) · 2020-12-31 17:02:11 UTC

You can use apt to install, follow any normal Ubuntu instructions

## Reply by Alex123 · 2021-01-07 12:43:03 UTC (in reply to Chad Sweet)

@Chad-Sweet 
I'm using the Ubuntu Docker container on VOXL.
OpenCV4 in Python3 is working.

But I'm facing issues while mounting sdcard on it.
I'm referring to [this link](https://docs.docker.com/engine/reference/commandline/run/).

I'm using the below command to mount sdcard.
docker run -v /mnt/sdcard:/root/yoctohome/:rw -w /root/ roskinetic-xenial:opencv

How can I mount a sdcard on the Ubuntu Docker container on VOXL?

## Reply by tom (ModalAI staff) · 2021-01-08 18:15:33 UTC (in reply to Alex123)

@Alex123 You should be able to mount the sdcard directory using the following param
```docker run -v /sdcard:/sdcard```

## Reply by Alex123 · 2021-01-14 06:52:49 UTC (in reply to tom)

@tom 
I've tried **docker run -v /sdcard:/sdcard**, but not working. It's not showing sdcard directory.

## Reply by tom (ModalAI staff) · 2021-01-15 19:57:31 UTC

@Alex123 here is the exact command I tested with on a VOXL. 

`docker run -it --rm --privileged --net=host --name roskinetic -v /home/root:/root/yoctohome/:rw -v /sdcard:/sdcard -w /root/ roskinetic-xenial:v1.0 /bin/bash`

Can you try this?
