Conflicting OpenCV and Matplotlib
<p>I have been trying to show images with opencv and plots with pyplot within the same script, but I will receive an error: <code>libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6</code> preceded by multiple lines of cryptic error log also shown on the issue <a href="https://stackoverflow.com/questions/32019556/matplotlib-crashing-tkinter-application">here</a>.</p>

<p>The minimal code to reproduce the issue is:</p>

<pre><code>import cv2
import numpy as np
import matplotlib
matplotlib.use("TkAgg")
from matplotlib import pyplot as plt

img = np.ones((50, 50), np.uint8)
cv2.imshow('image', img)
plt.figure()
plt.plot([1,2], [1,3])
plt.show()
</code></pre>

<p>The problem does not occur if I only use opencv or pyplot exclusively. Only using both libraries in the same script generates the problem.</p>

<p>I am using python 2.7, opencv 2.4.13 and matplotlib 1.5.1 (also tried 2.0.0b) from a virtual environment on Mac OS X El Capitan 10.11.3.</p>

<p>UPDATE: The code can be executed in a different order without errors:</p>

<pre><code>import cv2
import numpy as np
import matplotlib
matplotlib.use("TkAgg")
from matplotlib import pyplot as plt

plt.figure()
plt.plot([1,2], [1,3])
plt.show()
img = np.ones((50, 50), np.uint8)
cv2.imshow('image', img)
</code></pre>

<p>UPDATE 2: Running the code in a debugger (PyCharm) executes without errors and shows both graphics. Apparently something in the interactive mode bypasses the issue.</p>