cv2.waitKey(0) not working, OpenCV 3.1.0, Mac OS X 10.11.6, Python 2.7.12
<p>I have these two statement in the end of my python program:</p>

<pre><code>cv2.waitKey(0)
cv2.destroyAllWindows()
</code></pre>

<p>Somehow cv2.waitKey(0) not working, no response to keyboard input 0, to end my program I had to close my Mac terminal window.</p>

<p>I tried the following to fix the problem</p>

<pre><code>if cv2.waitKey(0) &amp; 0xFF == ord('q'):
    break
</code></pre>

<p>then I got this message:
SyntaxError: 'break' outside loop</p>

<p>Not sure what's wrong. I am using a Macbook Air, Mac OS X 10.11.6
Please help.</p>

<p>Thanks</p>