简体   繁体   中英

numpy.core.multiarray failed to import while invoking python module through C++ application developed in xcode

I am using anaconda to maintain python virtual environment. I have a python module which i want to invoke from c++ application developed through xcode 9.2.

pModule = PyImport_Import(pName) fails in c++ application with error

ImportError: numpy.core.multiarray failed to import.

pName here refers to a module xyz.py . xyz's __init__.py imports cv2 which in turn is using from .cv2 import * . This fails with error "numpy.core.multiarray failed to import". Packages for opencv and numpy is installed in same virtual environment still its not able to import numpy's core.multiarray module.

To me this doesn't seems to be a path issue, as I am using PySys_SetPath to set path where packages are installed , path looks like anaconda/envs/XYZ/lib/python3.5/site-packages .

Just to add more info, xyz module i am using is for object detection, to be more specific its imageAI object detection module. So under python3.5/site-packages I have imageai's Detection module ( python3.5/site-packages/imageai/Detection/). In Detection there is init .py which is trying to import cv2. The error received is when cv2 trying to import numpy.core.multiarray, both cv2 and numpy exists in path python3.5/site-packages.

What work it to reinstall numpy using conda NOT pip

pip uninstall numpy
conda install numpy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM