Exe created with py2exe doesn't work and returns logfile with errors

lottee picture lottee · Nov 24, 2013 · Viewed 8.1k times · Source

It's my first post so go easy on me. My problem is similar as in here, but I couldn't make it work, though I really tried: " py2exe with enthought and pandas ".

Having installed separately both versions of python(x84-64, x32) with libraries I proceeded to making an executable of python script using py2exe. I had to download missing dll files: msvcp90.dll, libiomp5md.dll, libifcoremd.dll, libmmd.dll.
Exe files I created return errors and a logfile is generated - different for x32 and x64 python&libraries.

For 32 bit python&libraries I got the following logfiles(different depending on which numpy library I installed from: http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy)

For numpy-1.8.0-win32-superpack-python2.7 I received multipled following information:

File "gui.py", line 7, in <module>
File "pyqtgraph\__init__.pyc", line 177, in <module>
File "pyqtgraph\__init__.pyc", line 167, in importAll
File "pyqtgraph\__init__.pyc", line 159, in importModules
Traceback (most recent call last):
File "gua.py", line 7, in <module>
File "pyqtgraph\__init__.pyc", line 180, in <module>
File "pyqtgraph\imageview\__init__.pyc", line 6, in <module>
File "pyqtgraph\imageview\ImageView.pyc", line 20, in <module>
File "pyqtgraph\imageview\ImageViewTemplate_pyqt.pyc", line 159, in <module>
File "pyqtgraph\widgets\PlotWidget.pyc", line 10, in <module>
File "pyqtgraph\graphicsItems\PlotItem\__init__.pyc", line 1, in <module>
File "pyqtgraph\graphicsItems\PlotItem\PlotItem.pyc", line 32, in <module>
File "pyqtgraph\graphicsItems\PlotDataItem.pyc", line 4, in <module>
File "pyqtgraph\graphicsItems\PlotCurveItem.pyc", line 4, in <module>
File "scipy\stats\__init__.pyc", line 324, in <module>
File "scipy\stats\stats.pyc", line 242, in <module>
File "scipy\special\__init__.pyc", line 531, in <module>
File "scipy\special\_ufuncs.pyc", line 12, in <module>
File "scipy\special\_ufuncs.pyc", line 10, in __load
File "_ufuncs.pyx", line 1, in init scipy.special._ufuncs (scipy\special\_ufuncs.c:19840)
ImportError: No module named _ufuncs_cxx

For numpy-MKL- 1.8.0.win32-py 2.7:

Traceback (most recent call last):
File "gui.py", line 2, in <module>
File "numpy\__init__.pyc", line 154, in <module>
File "numpy\add_newdocs.pyc", line 9, in <module>
File "numpy\lib\__init__.pyc", line 13, in <module>
File "numpy\lib\polynomial.pyc", line 17, in <module>
File "numpy\linalg\__init__.pyc", line 48, in <module>
File "numpy\linalg\linalg.pyc", line 23, in <module>
File "numpy\linalg\lapack_lite.pyc", line 12, in <module>
File "numpy\linalg\lapack_lite.pyc", line 10, in __load
ImportError: DLL load failed: %1 is not a valid Win32 application.

For numpy-MKL-1.7.2rc1.win32-py2.7 I received as above, but multiplied.

For 64 bit python&libraries I got the following, irrelatively of scipy and numpy version:

File "gui.py", line 7, in <module>
File "pyqtgraph\__init__.pyc", line 177, in <module>
File "pyqtgraph\__init__.pyc", line 167, in importAll
File "pyqtgraph\__init__.pyc", line 159, in importModules
Traceback (most recent call last):
File "pyqtgraph\__init__.pyc", line 155, in importModules
File "pyqtgraph\graphicsItems\PlotDataItem.pyc", line 4, in <module>
File "pyqtgraph\graphicsItems\PlotCurveItem.pyc", line 4, in <module>
File "scipy\stats\__init__.pyc", line 324, in <module>
File "scipy\stats\stats.pyc", line 242, in <module>
File "scipy\special\__init__.pyc", line 531, in <module>
File "scipy\special\_ufuncs.pyc", line 12, in <module>
File "scipy\special\_ufuncs.pyc", line 10, in __load
File "_ufuncs.pyx", line 1, in init scipy.special._ufuncs (scipy\special\_ufuncs.c:19992)
ImportError: No module named _ufuncs_cxx

I do have some ufuncs files in ..\build\bdist.win-amd64\winexe\collect-2.7\scipy\special , but I'm not sure how it works or should work.

So what do I do to make any of these .exe work? Preferably, the one that goes with 64-bit python, because opening the program by running the code in SciTe with 32-bit python took ages and there was a memory overload.

EDIT:

After removing import numpy, pyqtgraph, scipy from setup.py I get the following logfile with errors:

File "gui.py", line 7, in <module>
File "pyqtgraph\__init__.pyc", line 177, in <module>
File "pyqtgraph\__init__.pyc", line 167, in importAll
File "pyqtgraph\__init__.pyc", line 159, in importModules
Traceback (most recent call last):
File "pyqtgraph\__init__.pyc", line 155, in importModules
File "pyqtgraph\graphicsItems\PlotDataItem.pyc", line 4, in <module>
File "pyqtgraph\graphicsItems\PlotCurveItem.pyc", line 2, in <module>
File "scipy\fftpack\__init__.pyc", line 97, in <module>
File "scipy\fftpack\basic.pyc", line 12, in <module>
File "scipy\fftpack\_fftpack.pyc", line 12, in <module>
File "scipy\fftpack\_fftpack.pyc", line 10, in __load
ImportError: DLL load failed: %1 is not a valid Win32 application.

Answer

Pierre picture Pierre · Mar 19, 2014

I'm having more success with PyInstaller than Py2exe. In PyInstaller, the problem is solved by explicitly adding a reference:

pyinstaller myscript.py --hidden-import=scipy.special._ufuncs_cxx

PyInstaller also takes care of the matplotlib imbroglio, and Visual Studio DLLs.