8

System:

Windows 7 64-bit

Anaconda 2.7 64-bit

py2exe 64-bit

Background:

I converted my python code to .exe using py2exe and setup.py file shown below:

from distutils.core import setup
import py2exe

from distutils.filelist import findall
import matplotlib

opts = {"py2exe": {
    "packages" : ['matplotlib'],
    "includes": ['scipy', 'scipy.integrate', 'scipy.special.*','scipy.linalg.*'],
         'dll_excludes': ['libgdk-win32-2.0-0.dll',
                            'libgobject-2.0-0.dll',
            'libgdk_pixbuf-2.0-0.dll']
                     }
           }

setup(
      windows = [{'script': "with_GUI.py"}], zipfile = None,
      options= opts,
      data_files = matplotlib.get_py2exe_datafiles()
     )

But this gave me some error saying that there was version conflict with two files. So I changed the two files viz. dist/tcl/tcl8.5/init.tcl (in line 19) and dist/tcl/tk8.5/tk.tcl (in line 18). In my case I changed the version from 8.5.15 to 8.5.18. I found the location of the two files by looking at the path specified by the error in error log. Then the .exe worked just fine.

Problem:

I zipped the dist folder which contains .exe file. Then, I unzipped it on another computer but it is not working there. Following is the error it shows:

Traceback (most recent call last):
  File "Moment_Final.py", line 5, in <module>
  File "matplotlib\__init__.pyc", line 122, in <module>
  File "matplotlib\cbook.pyc", line 33, in <module>
  File "numpy\__init__.pyc", line 180, in <module>
  File "numpy\add_newdocs.pyc", line 13, in <module>
  File "numpy\lib\__init__.pyc", line 8, in <module>
  File "numpy\lib\type_check.pyc", line 11, in <module>
  File "numpy\core\__init__.pyc", line 14, in <module>
  File "numpy\core\multiarray.pyc", line 12, in <module>
  File "numpy\core\multiarray.pyc", line 10, in __load
ImportError: DLL load failed: The specified module could not be found.

Update: If I install Anaconda Python 2.7 on the system, there is no error. But then, what is the use of py2exe.

1 Answer 1

5

I encountered the same issue. The solution has been found on the link below :

http://comments.gmane.org/gmane.comp.python.py2exe/4847

In short, two dlls from "C:\Anaconda2\Library\bin" were missing in the "dist" output of py2exe.

2
  • Actually, in the end it worked after I copied all the DLL's in the C:\Anaconda2\Library\bin to the dist folder. Mar 18, 2016 at 17:06
  • 3
    For my case, it's the libiomp5md.dll, and the mkl_*.dll
    – Ewan
    Aug 10, 2016 at 6:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.