I am attempting to create a .exe on Windows 7 from a python3 script using cx_freeze. the Script involves using pywin32 to manipulate Excel files. I can build the .exe successfully from my setup.py file; however, when I run the .exe, the following error is thrown:
Traceback (most recent call last):
File "C:\Python33\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 27, in exec(code,m_dict_)
File "MyScript.py", line 12, in < module >
File "C:\Python\64-bit\3.3\lib\importlib_bootstrap.py", line 1558, in _find_and_load
File "C:\Python\64-bit\3.3\lib\importlib_bootstrap.py", line 1505, in _find_and_load_unlocked
File "C:\Python\64-bit\3.3\lib\importlib_bootstrap.py", line 313, in _call_with_frames_removed
File "C:\Python\64-bit\3.3\lib\importlib_bootstrap.py", line 1558, in _find_and_load
File "C:\Python\64-bit\3.3\lib\importlib_bootstrap.py", line 1525, in _find_and_load_unlocked
File "C:\Python33\lib\site-packages\win32com__init__.py", line 6, in < module>
import pythoncom
File "C:\Python\64-bit\3.3\lib\importlib_bootstrap.py", line 1558, in _find_and_load
File "C:\Python\64-bit\3.3\lib\importlib_bootstrap.py", line 1525, in _find_and_load_unlocked
File "C:\Python33\lib\site-packages\pythoncom.py", line 3, in
pywintypes._import_pywin32_system_module_("pythoncom", globals())File "C:\Python33\lib\site-packages\win32\lib\pywintypes.py", line 61, in _import_pywin32_system_module_
raise ImportError("Module '%s' isn't in frozen sys.path %s" % (modname, sys.path))
ImportError: Module 'pythoncom' isn't in frozen sys.path
['C:\Python33\build\exe.win-amd64\3.3\MyScript.exe',
'C:\Python33\build\exe.win-amd64\3.3',
'C:\Python33\build\exe.win-amd64\3.3\MyScript.zip',
'C:\Python33\build\exe.win-amd64\3.3\library.zip']
Here is what my setup.py file currently looks like:
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == 'win32':
base = 'Win32GUI'
includes = []
packages = []
executables = [Executable('MyScript.py', base=base)]
include_files = ['MyFolder1/','MyFolder2/Spreadsheet.xls']
setup(name='My Script',
version='0.1',
description='My Script',
executables=executables,
options = {'build_exe': {'includes':includes,
'packages':packages,
'include_msvcr':True,
'include_files':include_files}})
So far, I have tried listing both 'pythoncom' and 'win32com' in both the includes and the packages lists. Any help is greatly appreciated!