1

I am trying to make an executable with python, py2exe using Enthought. The program.py starts with:

import pandas as pd
import pyper as pr
r=pr.R(use_pandas=True)

The setup.py is as below:

from distutils.core import setup
import py2exe
import matplotlib
import sys
opts={"py2exe":{"bundle_files"}}
sys.argv.append('py2exe')
opts = {'py2exe': {"bundle_files" : 3, "includes" : [ "matplotlib.backends", "matplotlib.backends.backend_qt4agg", "pylab","numpy", "matplotlib.backends.backend_tkagg"], 'excludes':['_gtkagg', '_tkagg', '_agg2', '_cairo', '_cocoaagg', '_fltkagg', '_gtk', '_gtkcairo'], 'dll_excludes': ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll']}}
setup(console=['program.py'],zipfile=None,options=opts,data_files=matplotlib.get_py2exe_datafiles())

After running:python setup.py py2exe the two folders dist and build were created. But when launched program.exe I got this:

Dll load failed: The specified module could not be found
Traceback (most recent call last):  
File "program.py", line 1, in module  
File "pandas\__init__.pyc", line 6, in module  
File "pandas\hashtable.pyc", line 12, in module  
File "pandas\hashtable.pyc", line 10, in module  
File "numpy.pxd.", line 157, in init pandas.hastable (pandas\hastable.c:19547)  
File "numpy\__init__.pyc", line 143, in module  
File "numpy\lib\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: The specified module could not be found** 

I'm using Canopy 1.1.0 with Pandas 0.12.0-2 on a 64-Windows 7

Thanks for any help.

Gaston Cissé
  • 25
  • 1
  • 7
  • You seem to be missing a '"' before `matplotlib.backends.backend_qt4agg` `opts = {'py2exe': {"bundle_files" : 3, "includes" : [ "matplotlib.backends", "matplotlib.backends.backend_qt4agg",...` Aside from that don't you need to include `numpy` and `pandas`? – EdChum Sep 18 '13 at 10:44
  • Thanks! I ran `"matplotlib.backends.backend_qt4agg"`. `pandas` was used because `program.py` imports a csv file as dataframe. – Gaston Cissé Sep 18 '13 at 10:58
  • So are you saying this works now? If so I can post it as an answer – EdChum Sep 18 '13 at 11:21
  • No, it's not working. Still the same error. – Gaston Cissé Sep 18 '13 at 12:11

1 Answers1

2

It looks as though the .exe built by py2exe may be missing the Intel MKL DLLs that come with Canopy (EPD). Depending on which version of Canopy (EPD) you have, the NumPy DLLs may be linked against the Intel MKL DLLs. Those DLLs should be in C:\Python27\Scripts directory (or the corresponding Scripts directory if you've installed EPD in a different place) -- look for DLLs whose filename starts with mk2.


EDIT: The path above works only for older EPD versions. For a more recent version of Canopy, the DLLS are typically located somewhere like C:\Users\<user>\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.1.0-1371-win-x86_64\Scripts

Mark Dickinson
  • 24,977
  • 7
  • 71
  • 104
  • The mk2 dLLs are in `C:\Users\~\AppData\Local\Enthought\Canopy32\App\appdata\canopy-1.1.0.1371.win-x86\Scripts` and it's still not working. However the problem has been solved with pyinstaller. Thanks – Gaston Cissé Sep 20 '13 at 07:41
  • Ah, thanks. I missed the bit where you said you were using Canopy 1.1.0; the C:/Python27 path was valid for older EPDs. I'll update the answer. – Mark Dickinson Sep 20 '13 at 09:40