question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'numpy.core._multiarray_umath' not found on embedded Python, but found on console.

See original GitHub issue

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.

The application sets Py_SetPythonHome() to my Python folder: C:\Users\MyName\AppData\Local\Programs\Python\Python37-32

print(os.file) prints the correct file.

Reproducing code example:

Py_SetProgramName(Py_DecodeLocale(ProgramName,0));
Py_SetPythonHome(Py_DecodeLocale("C:\\Users\\Richard\\AppData\\Local\\Programs\\Python\\Python37-32",0));
Py_Initialize();
PyModuleMain = PyImport_AddModule("__main__");
PyGlobalDict = PyModule_GetDict(PyModuleMain);
const char *Content = "import os; print(os.__file__)\nimport numpy";
PyRun_SimpleString(Content);
import os; print(os.__file__)
import numpy

Error message:

Traceback (most recent call last): File “C:\Users\Richard\AppData\Local\Programs\Python\Python37-32\lib\site-packages\numpy\core_init_.py”, line 40, in <module> from . import multiarray File “C:\Users\Richard\AppData\Local\Programs\Python\Python37-32\lib\site-packages\numpy\core\multiarray.py”, line 12, in <module> from . import overrides File “C:\Users\Richard\AppData\Local\Programs\Python\Python37-32\lib\site-packages\numpy\core\overrides.py”, line 6, in <module> from numpy.core._multiarray_umath import ( ModuleNotFoundError: No module named ‘numpy.core._multiarray_umath’

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “<string>”, line 2, in <module> File “C:\Users\Richard\AppData\Local\Programs\Python\Python37-32\lib\site-packages\numpy_init_.py”, line 142, in <module> from . import core File “C:\Users\Richard\AppData\Local\Programs\Python\Python37-32\lib\site-packages\numpy\core_init_.py”, line 71, in <module> raise ImportError(msg) ImportError: …

Numpy/Python version information:

1.16.2, 3.7 32 bit Windows

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:28 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
elikosancommented, May 17, 2019

My problem was that I was building the embedded python in Debug mode. In this case python appends a _d to the suffixes when loading files. However, numpy installation did not include those files, so the import would fail.

0reactions
spartha77commented, Apr 8, 2020

I too had the same problem. I solved it. My problem statement: (Windows)

-> I had installed Python3.5 at C:\Python35, -> I invoked Python and ran “import numpy” It gave rise to similar problem. << I then realized that the numpy installation was at C:\Users\partha3x\AppData\Roaming\Python\Python37\site-packages\numpy\core\ and NOT from the path I had mentioned at the time of installation. -> So, I modified (re-installed) python at the user profile home directory. -> The home profile directory is C:\Users\partha3x\AppData\Local\Programs\Python\Python37 ->Uninstalled the numpy ->Re-installed numpy With this “import numpy” call succeeded in python

With Visual Studio 2019, I had the same problem. I followed the following steps -> Uninstalled all Pythons that which were installed using VIsual Studio installer. (Not sure if this step helped me) -> In the project properties, in which I was invoking Python (embedded Python) from C++ project, I had set additional Libraries ( Project properties->Linker->General->Additional Library Directories I added C:\Users\partha3x\AppData\Roaming\Python\Python37\site-packages\numpy\core\lib AND -> In the project properties -> Linker->Input->Additional Dependencies , I added npymath.lib.

These fixed the issues.

In Linux, similar to the project properties, the files have to be compiled with additional dependencies with additional directories using make files.

Hope this helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No module named 'numpy.core._multiarray_umath' (While ...
I upgraded numpy to 1.16.1 version and tried again the above command: python -c "import tensorflow as tf; tf.enable_eager_execution(); ...
Read more >
No module named 'numpy.core._multiarray_umath - (View topic)
From the APSO console in libreoffice base, I am trying to use the numpy module. When I type the command: Code: Select all...
Read more >
Original error was: No module named 'numpy.core ...
Original error was: No module named 'numpy.core._multiarray_umath' after installed pythran. Subscribe. More actions.
Read more >
Error importing C-extensions for Numpy on Win10 Conda Env
I have setup an apache installation through WAMP on windows and connected it to a ... importing _multiarray_umath: The specified module could not...
Read more >
tensorflow-metal | Apple Developer Forums
Tensorflow text package is not available for M1. ... module compiled against API version 0x10 but this version of numpy is 0xf ImportError:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found