Issue 305: Unable to import decimal with py2exe generated Executable
Status:  NoFix
Owner: ----
Closed:  Mar 2013
Reported by Anu...@mimansa.cl, Jan 9, 2013
What steps will reproduce the problem?

I generated a executable using py2exe on a windows machine. However, the generated executable fails to execute with the error indicated below.

D:\ScannerTool\dist>SerialTool.exe
Traceback (most recent call last):
  File "SerialTool.py", line 2, in <module>
  File "pyodbc.pyc", line 12, in <module>
  File "pyodbc.pyc", line 10, in __load
RuntimeError: Unable to import decimal

I am running on Windows XP SP3 32 Bit.

I read on the link http://www.py2exe.org/index.cgi/PyODBC that by including an additional option, i can get around this error but despite having generated the executable with this option, the error persists.

Appreciate your help on this.

Here is my setup.py for reference.

from distutils.core import setup
import py2exe , sys
from glob import glob
sys.path.append('C:\\WINDOWS\\WinSxS\\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.6195_x-ww_44262b86')
#setup(options = {"py2exe": { "dll_excludes": ["OCI.dll"],"includes": "decimal"}},)
setup(options = {"py2exe": {"includes": "decimal"}},)
setup(console=['SerialTool.py'])


Regards,
Anurag
Jan 9, 2013
#1 Anu...@mimansa.cl
Just solved this. Besides putting an option in the setup.py file, I should also include an import of decimal module in my SerialTool.py script. 

I could not find a way to close this issue.

Regards,
Anurag
Mar 28, 2013
Project Member #2 mkleehammer
(No comment was entered for this change.)
Status: NoFix
Sep 15, 2014
#3 csmcpher...@gmail.com
The option simply needs to be added to same call to setup, eg:

setup(
    console=['setup.py'],
    options={"py2exe": {"includes": "decimal"}}
)