This is a simple piece of code that executes with no problems from the command line (Python Anaconda 3.5):
import cv2
image = cv2.imread('image.jpg')
a=image.shape[0]
b=image.shape[1]
print("image size " + str(a) + " by " + str(b))
When it runs, you get the expected:
image size 3254 by 4928
However, when running from notepad++ 7.8.1, Windows 7), I get:
Traceback (most recent call last):
File "C:\Users\Me\Desktop\test.py", line 3, in <module>
a=image.shape[0]
AttributeError: 'NoneType' object has no attribute 'shape'
C:\Program Files (x86)\Notepad++>
This seems odd. The shortcut for python in Notepad++ is located in C:\Users\Me\AppData\Roaming\Notepad++ , in 'shortcuts.xml'. This is:
<Command name="python_35" Ctrl="no" Alt="no" Shift="no" Key="0">cmd /K python "$(FULL_CURRENT_PATH)"</Command>
Any thoughts on why this might not be working? If I type 'cmd /K python', I do get the Anaconda version of python (I was wondering if I was seeing another version of python on my system). This doesn't fail on reading the image, so I'm thinking OpenCV is still being loaded.