Win10 / Pyinstaller ImportError: numpy.core.multiarray failed to import

Viewed 3030

Summary

I just wrote a Python (3.7.2) program and an using Pyinstaller (3.4) to compile it to an exe. The Python file is using opencv-python (which required numpy) as a dependency. Despite having looked for a while, none of the solutions I have seen online have worked for me.

I do not have anaconda installed, not do I have multiple versions of any of the libs I am using (including Python itself).

Also, when I run 'from numpy import multiarray' in python, even that prints out an error that it cannot do the import.

What I have tried

unistalling and reinstalling numpy and opencv-python

updating numpy to the latest version (1.16).

Running pyinstaller on the program in Windows 10 and 7 VMs in addition to my native Windows 10 (with all dependencies installed prior via pip, of course) (A quick note--when I ran on Win7 I did not get any of the 'lib not found:' errors that I saw in Win10, but the program still failed to run)

None of these results made a difference in the error message I received that 'numpy.core.multiarray failed to import'.

The question

How do I get my program to compile to an exe? I'm open to using a different program (other than pyinstaller).

Thank you!!

The data I have

Here is the error message from running 'from numpy import multiarray' in a python terminal:

ImportError: cannot import name 'multiarray' from 'numpy' (C:\Users\name\AppData\Local\Programs\Python\Python37-32\lib\site-packages\numpy\__init__.py)

Here is the full error message from attempting to run the compiled exe

PS C:\Users\name\Downloads\py\dist\SignRecorder> .\SignRecorder.exe
ImportError: numpy.core.multiarray failed to import
Traceback (most recent call last):
File "SignRecorder.py", line 1, in <module>
File "c:\users\name\appdata\local\programs\python\python37-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\cv2\__init__.py", line 3, in <module>
ImportError: numpy.core.multiarray failed to import
[15208] Failed to execute script SignRecorder

Here is the final build output from pyinstaller

C:\Users\name\Downloads\py\build\SignRecorder\SignRecorder.exe
19881 INFO: Building EXE from EXE-00.toc completed successfully.
19893 INFO: checking COLLECT
19893 INFO: Building COLLECT because COLLECT-00.toc is non existent
19894 INFO: Building COLLECT COLLECT-00.toc
28366 INFO: Building COLLECT COLLECT-00.toc completed successfully.
1 Answers

Thanks to Rick M, I was able to find out that my versions were too recent and did not work well with each other. The configuration I used that worked was:

Python 3.5 or 3.7.2 (latest as of 01 / 23 / 2019)

Pyinstaller 3.4

numpy 1.15

Related