尝试将我的程序转换为使用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文件中。所以我也尝试过,但无济于事。有任何想法吗?
提前致谢!

最佳答案

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

关于python - py2exe:找不到dbm克隆,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18221307/

10-11 18:58