1

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

4

1 回答 1

1

Sorry I was wrong, all I had to do was import dbhash along with anydbm at the beginning of the python file. (Not the setup.py)

于 2013-08-14T16:45:05.240 回答