Search code examples
pythonopencvraspberry-pi3geany

RaspberryPi: ImportError: No module named cv2 in Geany


I installed opencv in RaspberryPi (using this link)and import in termial and python3 (idle). It shows no error in these two as shown in below images.

enter image description here enter image description here

But, when I tried to run import cv2 in Geany, it shows error given below:

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

How I can solve this problem?


Solution

  • I solved this problem by changing python to python3 in Geany. For this, Go to Build->Set Build Commands in Geany menu. In Set Build Commandswindow, under Python commands label in compile line python m py_compile will be there. Similarly, under Executive commands label in executive line python "%f" will be there. I changed python m py_compile into python3 m py_compile and python "%f" into python3 "%f" (as shown in images 1 and 2) and above-mentioned problem get solved.

    Image 1.

    enter image description here

    Image2.

    **enter image description here**

    Thanks.