<p dir="auto">Hello,</p>
<p dir="auto">There's a bunch of packages which I'm installing that requires NumPy (for example TensorFlow), and I can't seem to be able to install and import them because of an ImportError on the numpy side.</p>
<p dir="auto">This is happening with both <code class="notranslate">pip install</code> and building from source.</p>
<h3 dir="auto">Reproducing code example:</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
import tensorflow as tf"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">import</span> <span class="pl-s1">tensorflow</span> <span class="pl-k">as</span> <span class="pl-s1">tf</span></pre></div>
<h3 dir="auto">Error message:</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ImportError: numpy.core._multiarray_umath failed to import"><pre class="notranslate"><code class="notranslate">ImportError: numpy.core._multiarray_umath failed to import
</code></pre></div>
<h3 dir="auto">Numpy/Python version information:</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="'1.16.0.dev0+cdbf35b'"><pre class="notranslate"><code class="notranslate">'1.16.0.dev0+cdbf35b'
</code></pre></div>
<p dir="auto">I have unearthed a very strange problem when combining using Gauss-Hermite quadrature in a script that also does some plotting.</p>
<h4 dir="auto">Minimal example</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt
import numpy as np
plt.plot([0, 1], [0, 1], 'k--')
degree = 11
np.polynomial.hermite.hermgauss(degree)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-s1">plt</span>.<span class="pl-en">plot</span>([<span class="pl-c1">0</span>, <span class="pl-c1">1</span>], [<span class="pl-c1">0</span>, <span class="pl-c1">1</span>], <span class="pl-s">'k--'</span>)
<span class="pl-s1">degree</span> <span class="pl-c1">=</span> <span class="pl-c1">11</span>
<span class="pl-s1">np</span>.<span class="pl-s1">polynomial</span>.<span class="pl-s1">hermite</span>.<span class="pl-en">hermgauss</span>(<span class="pl-s1">degree</span>)</pre></div>
<h4 dir="auto">Error message</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;..\TransfectionOXB\np_bug.py&quot;, line 5, in &lt;module&gt;
    np.polynomial.hermite.hermgauss(degree)
  File &quot;c:\depot\XXX\venv\lib\site-packages\numpy\polynomial\hermite.py&quot;, line 1586, in hermgauss
    x = la.eigvalsh(m)
  File &quot;&lt;__array_function__ internals&gt;&quot;, line 6, in eigvalsh
  File &quot;c:\depot\XXX\venv\lib\site-packages\numpy\linalg\linalg.py&quot;, line 1176, in eigvalsh
    w = gufunc(a, signature=signature, extobj=extobj)
  File &quot;c:\depot\XXX\venv\lib\site-packages\numpy\linalg\linalg.py&quot;, line 94, in _raise_linalgerror_eigenvalues_nonconvergence
    raise LinAlgError(&quot;Eigenvalues did not converge&quot;)
numpy.linalg.LinAlgError: Eigenvalues did not converge"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "..\TransfectionOXB\np_bug.py", line 5, in &lt;module&gt;
    np.polynomial.hermite.hermgauss(degree)
  File "c:\depot\XXX\venv\lib\site-packages\numpy\polynomial\hermite.py", line 1586, in hermgauss
    x = la.eigvalsh(m)
  File "&lt;__array_function__ internals&gt;", line 6, in eigvalsh
  File "c:\depot\XXX\venv\lib\site-packages\numpy\linalg\linalg.py", line 1176, in eigvalsh
    w = gufunc(a, signature=signature, extobj=extobj)
  File "c:\depot\XXX\venv\lib\site-packages\numpy\linalg\linalg.py", line 94, in _raise_linalgerror_eigenvalues_nonconvergence
    raise LinAlgError("Eigenvalues did not converge")
numpy.linalg.LinAlgError: Eigenvalues did not converge
</code></pre></div>
<h4 dir="auto">Surprising workarounds/fixes</h4>
<p dir="auto">I have no idea why there is any dependency of hermgauss on matplotlib, but the following observations make this even more surprising:</p>
<ul dir="auto">
<li>Using <code class="notranslate">degree</code> &lt; 10 resolves the problem</li>
<li>Changing the plot format from <code class="notranslate">--</code> to <code class="notranslate">-</code> (or anything else) also resolves the problem</li>
</ul>
<h4 dir="auto">Version information</h4>
<p dir="auto">I believe this is a problem on Windows only, as a colleague using Windows verified this bug on his system, while a mac user did not receive any error message.<br>
I'm currently using:</p>
<ul dir="auto">
<li>Windows 10 Enterprise, version 2004, OS build 19041.450</li>
<li>python version 3.7.8</li>
<li>numpy version 1.19.1</li>
<li>matplotlib version 3.3.1</li>
</ul>
<p dir="auto">I've tried it on a few other versions of numpy and matplotlib, but there is no difference.</p>