py2exe:找不到dbm clone

时间:2013-08-14 00:18:13

标签: python py2exe

尝试将我的程序转换为使用anydbm的可执行文件,并得到此响应:

Traceback (most recent call last):
  File "sliceReg.py", line 14, in <module>
  File "registration.pyc", line 3, in <module>
  File "chamfer.pyc", line 4, in <module>
  File "sliceTools.pyc", line 3, in <module>
  File "dbUtils.pyc", line 5, in <module>
  File "anydbm.pyc", line 53, in <module>
ImportError: no dbm clone found; tried ['dbhash', 'gdbm', 'dbm', 'dumbdbm']

经过一些激烈的谷歌搜索,我的setup.py现在看起来像:

from distutils.core import setup
import py2exe
import glob
import numpy



opts = {
    'py2exe': { 'includes': ['dbhash', 'anydbm', 'skimage'],
    'excludes': ['_gtkagg', '_tkagg'],
    'dll_excludes': ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll']
                 }
    }   

for i in ['dbhash', 'gdbm', 'dbm', 'dumbdbm']:
    try: eval('import '+i)
    except: pass

setup(
    data_files = [('Images', glob.glob('Images/*.*')), 
    ('templates', glob.glob('data/templates/*.*'))],
    windows = ['MY_PROGRAM.py']
    )

我还读到我应该添加

for i in ['dbhash', 'gdbm', 'dbm', 'dumbdbm']:
    try: eval('import '+i)
    except: pass

在导入anydbm的实际.py文件中。所以我也试过了,但无济于事。有任何想法吗? 提前致谢!

1 个答案:

答案 0 :(得分:1)

抱歉,我错了,我所要做的就是在python文件的开头导入dbhash和anydbm。 (不是setup.py)