Embedded python in C : Is there a way to import numpy properly from zipped python archive? Embedded python in C : Is there a way to import numpy properly from zipped python archive? numpy numpy

Embedded python in C : Is there a way to import numpy properly from zipped python archive?


The best way is probably to unzip it for now. The zipimport module is what Python uses to load modules from zip files and unfortunately it disallows the import of dynamic compiled code (probably due to security concerns, consistent with PEP 273):

Any files may be present in the zip archive, but only files *.py and.py[co] are available for import. Zip import of dynamic modules (.pyd, *.so) is disallowed.

Because the wheels provided will be platform wheels, you will also need to remove the platform extension from the .so filenames which are added by Cython as part of adherence to PEP 3149. I.e., foo.cpython-XYm.so would need to be renamed to foo.so. (Since your question asks about Python 2, this does not apply but it does going forward for Python 3)

Lastly, the unzipped folders will need to be added to the PYTHONPATH if they are not already on it.