<p dir="auto">I can import numpy in the Python console, but cannot import it in an embedded python C++ application that used the same Python version with the same folders. I have only this Python version on my PC. Importing other packages from the application works.</p>
<p dir="auto">The application sets Py_SetPythonHome() to my Python folder:<br>
C:\Users\MyName\AppData\Local\Programs\Python\Python37-32</p>
<p dir="auto">print(os.<strong>file</strong>) prints the correct file.</p>
<h3 dir="auto">Reproducing code example:</h3>
<div class="highlight highlight-source-c++ notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Py_SetProgramName(Py_DecodeLocale(ProgramName,0));
Py_SetPythonHome(Py_DecodeLocale(&quot;C:\\Users\\Richard\\AppData\\Local\\Programs\\Python\\Python37-32&quot;,0));
Py_Initialize();
PyModuleMain = PyImport_AddModule(&quot;__main__&quot;);
PyGlobalDict = PyModule_GetDict(PyModuleMain);
const char *Content = &quot;import os; print(os.__file__)\nimport numpy&quot;;
PyRun_SimpleString(Content);"><pre class="notranslate"><span class="pl-en">Py_SetProgramName</span>(Py_DecodeLocale(ProgramName,<span class="pl-c1">0</span>));
<span class="pl-en">Py_SetPythonHome</span>(Py_DecodeLocale(<span class="pl-s"><span class="pl-pds">"</span>C:<span class="pl-cce">\\</span>Users<span class="pl-cce">\\</span>Richard<span class="pl-cce">\\</span>AppData<span class="pl-cce">\\</span>Local<span class="pl-cce">\\</span>Programs<span class="pl-cce">\\</span>Python<span class="pl-cce">\\</span>Python37-32<span class="pl-pds">"</span></span>,<span class="pl-c1">0</span>));
<span class="pl-en">Py_Initialize</span>();
PyModuleMain = PyImport_AddModule(<span class="pl-s"><span class="pl-pds">"</span>__main__<span class="pl-pds">"</span></span>);
PyGlobalDict = PyModule_GetDict(PyModuleMain);
<span class="pl-k">const</span> <span class="pl-k">char</span> *Content = <span class="pl-s"><span class="pl-pds">"</span>import os; print(os.__file__)<span class="pl-cce">\n</span>import numpy<span class="pl-pds">"</span></span>;
<span class="pl-en">PyRun_SimpleString</span>(Content);</pre></div>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import os; print(os.__file__)
import numpy"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">os</span>; <span class="pl-en">print</span>(<span class="pl-s1">os</span>.<span class="pl-s1">__file__</span>)
<span class="pl-k">import</span> <span class="pl-s1">numpy</span></pre></div>
<h3 dir="auto">Error message:</h3>
<p dir="auto">Traceback (most recent call last):<br>
File "C:\Users\Richard\AppData\Local\Programs\Python\Python37-32\lib\site-packages\numpy\core_<em>init</em>_.py", line 40, in <br>
from . import multiarray<br>
File "C:\Users\Richard\AppData\Local\Programs\Python\Python37-32\lib\site-packages\numpy\core\multiarray.py", line 12, in <br>
from . import overrides<br>
File "C:\Users\Richard\AppData\Local\Programs\Python\Python37-32\lib\site-packages\numpy\core\overrides.py", line 6, in <br>
from numpy.core._multiarray_umath import (<br>
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'</p>
<p dir="auto">During handling of the above exception, another exception occurred:</p>
<p dir="auto">Traceback (most recent call last):<br>
File "", line 2, in <br>
File "C:\Users\Richard\AppData\Local\Programs\Python\Python37-32\lib\site-packages\numpy_<em>init</em>_.py", line 142, in <br>
from . import core<br>
File "C:\Users\Richard\AppData\Local\Programs\Python\Python37-32\lib\site-packages\numpy\core_<em>init</em>_.py", line 71, in <br>
raise ImportError(msg)<br>
ImportError:<br>
...</p>
<h3 dir="auto">Numpy/Python version information:</h3>
<p dir="auto">1.16.2, 3.7 32 bit Windows</p>
<p dir="auto">I recently wanted to use the same way to construct a <code class="notranslate">linspace</code> as I did with an <code class="notranslate">mgrid</code>, i.e</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="T_size = slice(2, 30, 1)
P_size = slice(0, 80, 2)
grid = np.mgrid[T_size, P_size]

....

linspace = np.linspace(T_size)
# BOOM... exception"><pre class="notranslate"><code class="notranslate">T_size = slice(2, 30, 1)
P_size = slice(0, 80, 2)
grid = np.mgrid[T_size, P_size]

....

linspace = np.linspace(T_size)
# BOOM... exception
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TypeError: _linspace_dispatcher() missing 1 required positional argument: 'stop'"><pre class="notranslate"><code class="notranslate">TypeError: _linspace_dispatcher() missing 1 required positional argument: 'stop'
</code></pre></div>
<p dir="auto">I think that interoperability here would be great.</p>