import cv2 – no module named cv2

I have recently installed and compiled opencv on my raspberry. Now, when I try to use the import cv2 command on the thorny IDE in my raspbianOS, it returns an error stating that no module named cv2 exists, but that # 39; it runs correctly if I use the same command in my raspberrypi shell. What is the reason behind that.