I am also trying to convert a python script to an exe using py2exe. The python script is associated with an ArcToolBox, and it works fine as a python file but not as an exe.
I have excluded arcgisscripting module from the setup.py:
from distutils.core import setup
import py2exe
import os
opts = {"py2exe": {"includes":["doc_if_comunes"],
"excludes":['_ssl', "arcgisscripting",
'pyreadline', 'difflib', 'doctest', 'locale',
'optparse', 'pickle', 'calendar'],
"dist_dir":r"W:\0_FUENTES_PROGRAMAS\DOCUMENTACION_INCENDIOS\dist\DOCUMENTACION_INCENDIOS"}}
setup(windows=[os.getcwd() + 'PerimetrosAFrentes.py'],options=opts)
Path to arcgisscripting is set in PerimetroAFrentes.py:
import sys
sys.path.append(r'C:\Archivos de programa\ArcGIS\Bin')
import os
import doc_if_comunes
import arcgisscripting
import string, tempfile
gp = arcgisscripting.create(9.3)
gp.SetProduct("ArcInfo")
def Principal():
gp.AddToolbox(doc_if_comunes.pathArcGIS() + r"ArcToolbox\Toolboxes\Data Management Tools.tbx")
#lineas temporal
tempdir = tempfile.gettempdir()
li_tmp = os.path.join(tempdir,"shp_lines.shp")
if gp.Exists(li_tmp): gp.Delete(li_tmp)
gp.AddWarning(str(gp.Exists(r'ACTUAL\LINEAS')))
desc = gp.Describe(r'ACTUAL\LINEAS')
fc_li_a = desc.CatalogPath
arcgisscripting is properly imported as gp is created, shp_lines deleted and gp.Exists(r'ACTUAL\LINEAS') returns true (LINEAS is a feature layer in ArcMap). Nevertheless, the program breaks down in desc = gp.Describe(r'ACTUAL\LINEAS'). The following Error is written down in a log file:
RuntimeError: ERROR 999999: Error executing function.
PerimetrosAFrentes.py works correctly and gp is properly created, but I don´t figure out why PerimetrosAFrentes.exe colapses in gp.Describe. Any advice will be appreciated.