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

3

10

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.
Hylozoism answered 24/11, 2013 at 0:35 Comment(3)
I'm not sure what it is exactly. All I know it's a part of scipy library.Hylozoism
FWIW, I've always had far more luck with cx_freeze than py2exe.Subtangent
_funcs_cxx is part of the c-extensions that numpy/scipy uses to generalize operation application/broadcasting (stands for universal function I think). The fftpack include fortran extensions.Eliciaelicit
N
1

from distutils.core import setup

import py2exe

setup(console=['hello.py'])

edit : do not include any other libraries/modules here

NEXT at the cmd:

python hello.py py2exe

Nomo answered 25/11, 2013 at 10:21 Comment(9)
Yes, this is almost exactly what I do, but it still doesn't work. from distutils.core import setup import py2exe import numpy, pyqtgraph, scipy setup(windows=['gui.py'])Hylozoism
This program is quite important, because it's for my internship. Please help solve the problem.Hylozoism
I dont think you should import anything else at the scriptNomo
Just change the file name and not anything elseNomo
Ok, I did that. Now it returns what I've just added at the end of my question.Hylozoism
Is py2exe win32 or win64?Nomo
It x64. Actually it's py2exe-0.6.9.winx64-py2.7.amdx64Hylozoism
Try reinstalling etc. or the library is corrupted or wrong format.Nomo
And the library i meant is the _ufuncs_cxx etc.Nomo
H
12

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.

Homozygous answered 19/3, 2014 at 0:6 Comment(0)
N
1

from distutils.core import setup

import py2exe

setup(console=['hello.py'])

edit : do not include any other libraries/modules here

NEXT at the cmd:

python hello.py py2exe

Nomo answered 25/11, 2013 at 10:21 Comment(9)
Yes, this is almost exactly what I do, but it still doesn't work. from distutils.core import setup import py2exe import numpy, pyqtgraph, scipy setup(windows=['gui.py'])Hylozoism
This program is quite important, because it's for my internship. Please help solve the problem.Hylozoism
I dont think you should import anything else at the scriptNomo
Just change the file name and not anything elseNomo
Ok, I did that. Now it returns what I've just added at the end of my question.Hylozoism
Is py2exe win32 or win64?Nomo
It x64. Actually it's py2exe-0.6.9.winx64-py2.7.amdx64Hylozoism
Try reinstalling etc. or the library is corrupted or wrong format.Nomo
And the library i meant is the _ufuncs_cxx etc.Nomo
S
1

I got the same error message during creating .exe file using py2exe

File "_ufuncs.pyx", line 1, in init scipy.special._ufuncs (scipy\special\_ufuncs.c:22830)

It was resolved by adding scipy.special._ufuncs_cxx to the includes option in setup.py. Here is what I have.

from distutils.core import setup
import py2exe
import numpy

setup(
    console=['hello.py'],
    options={
        'py2exe': {
            r'includes': [r'scipy.sparse.csgraph._validation',
                          r'scipy.special._ufuncs_cxx']
        }
    }
)

Please note that it includes some other settings to prevent numpy/scipy related errors.

  • import numpy
  • includes scipy.sparse.csgraph._validation based on this answer
Schizo answered 15/7, 2014 at 12:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.