Numpy Pyinstaller ImportError: Unable to import multiarray name

I am facing a similar issue with the post here , which seems to be an unresolved issue.

After compiling exe, the pyinstaller collector generates the following error, which is most likely caused by numpy \ core \ init.py

There are several suggestions that are related to conflicting numpy installations, however I uninstalled and reinstalled several times and searched for any other installations without any luck. Currently working with binary files numpy-1.9 + MKL.

I also marked the multiarray.pyd file in the spec file as a binary to capture. Bad luck.

I do not know what causes this, since I am not particularly familiar with the init file structure. Any idea how to import this?

Error Tracking:

Traceback (most recent call last): File "<string>", line 50, in <module> File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module exec(bytecode, module.__dict__) File "C:\Users\Hp\PycharmProjects\GISdev\build\gis_helper2\out00-PYZ.pyz\mpl_toolkits.basemap", line 15, in <module> File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module exec(bytecode, module.__dict__) File "C:\Users\Hp\PycharmProjects\GISdev\build\gis_helper2\out00-PYZ.pyz\matplotlib", line 133, in <module> File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module exec(bytecode, module.__dict__) File "C:\Users\Hp\PycharmProjects\GISdev\build\gis_helper2\out00-PYZ.pyz\matplotlib.rcsetup", line 19, in <module> File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module exec(bytecode, module.__dict__) File "C:\Users\Hp\PycharmProjects\GISdev\build\gis_helper2\out00-PYZ.pyz\matplotlib.colors", line 52, in <module> File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module exec(bytecode, module.__dict__) File "C:\Users\Hp\PycharmProjects\GISdev\build\gis_helper2\out00-PYZ.pyz\numpy", line 200, in <module> File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module exec(bytecode, module.__dict__) File "C:\Users\Hp\PycharmProjects\GISdev\build\gis_helper2\out00-PYZ.pyz\numpy.add_newdocs", line 13, in <module> File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module exec(bytecode, module.__dict__) File "C:\Users\Hp\PycharmProjects\GISdev\build\gis_helper2\out00-PYZ.pyz\numpy.lib", line 8, in <module> File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module exec(bytecode, module.__dict__) File "C:\Users\Hp\PycharmProjects\GISdev\build\gis_helper2\out00-PYZ.pyz\numpy.lib.type_check", line 11, in <module> File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module exec(bytecode, module.__dict__) File "C:\Users\Hp\PycharmProjects\GISdev\build\gis_helper2\out00-PYZ.pyz\numpy.core", line 14, in <module> ImportError: cannot import name multiarray 

Possible cause of the problem taken from the initialization file:

 from __future__ import division, absolute_import, print_function from .info import __doc__ from numpy.version import version as __version__ # disables OpenBLAS affinity setting of the main thread that limits # python threads or processes to one core import os envbak = os.environ.copy() if 'OPENBLAS_MAIN_FREE' not in os.environ: os.environ['OPENBLAS_MAIN_FREE'] = '1' if 'GOTOBLAS_MAIN_FREE' not in os.environ: os.environ['GOTOBLAS_MAIN_FREE'] = '1' from . import multiarray os.environ.clear() os.environ.update(envbak) del envbak del os from . import umath from . import _internal # for freeze programs from . import numerictypes as nt multiarray.set_typeDict(nt.sctypeDict) 
+6
source share
2 answers

After exchanging comments, the problem was isolated from the problem in the user .spec file used by the OP. In .spec , a line like:

 coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, strip=None, upx=True, name='nptest') 

has been replaced by

 coll = COLLECT(exe, a.binaries1, a.zipfiles, a.datas, strip=None, upx=True, name='nptest') 

to try and enter a.binaries1 to allow pyinstaller to use some custom binary .dll .

In face a.binaries is a member of the Analysis object and should remain - the way to add an additional binary gile to the collection string is as follows ( according to the docs ). note that you can change the file name in your distribution (if necessary) by changing the first member of the tuple.

 coll = COLLECT(exe, a.binaries+[('zipcontainer.dll','C:\\Windows\\System32\\zipcontainer.dll','BINARY')], a.zipfiles, a.datas, strip=None, upx=True, name='nptest') 
+3
source

I am using Pycharm IDE and Anaconda on 64 bit Windows 10.

I solved the problem by following these steps:

  • remove numpy in anaconda;
  • delete the numpy files associated with it in the folder C: \ Users (computer_name) \ AppData \ Roaming \ Python \ Python35 \ site-packages
  • reinstall numpy in Anaconda

In your case, I suppose you could reinstall numpy after deleting the files in the folder C: \ Python27 \ Lib \ site-packages \ PyInstaller \ loader \

+1
source

All Articles