Willeman
Willeman

Reputation: 748

Importing Numpy in embedded Python c++ application

I would like to have a script invoke numpy from a c++ embedded python runtime by setting the runtime path to know about the numpy module located within site-packages.

However I get the error:

cannot import name 'multiarray'

from \Lib\site-packages\numpy\core__init_.py on the line

from . import multiarrray

I have tried to set the os.path to be xxx\numpy\core but it still cannot seem to find the multiarray.pyd file during the import statement

I have read through similar questions posed but none of the answers seem relevant to my case.

I am using Python 3.4.4 (32 bit) and have installed Numpy 1.11.1 using the wheel numpy-1.11.1-cp34-none-win32.whl

python -m pip install numpy-1.11.1-cp34-none-win32.whl

Completed without any errors.

Seems like the failure message maybe more general than just an incomplete PYTHONPATH?

Also think it might be broader than Numpy in that ANY .pyd based package that is imported from the embedded environment will have this problem?

Any help appreciated.

Upvotes: 1

Views: 2051

Answers (2)

Matt
Matt

Reputation: 2832

Did you ensure all your NumPy includes: \numpy\core\include\numpy\ were present during the build? That's the only time I get those types of errors was if the build couldn't find all the NumPy includes... although during embedding I found that the numpy entire directory (already built on your build machine) has to be inside a directory under Py_SetPath(python35.lib;importlibs); assuming importlibs is a directory with NumPy inside and anything else you want to bundle.

Upvotes: 1

Willeman
Willeman

Reputation: 748

Seems like the answer was to install python 3.4.1 to match the python34.dll version of 3.4.1.

Upvotes: 0

Related Questions