首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cx_Freeze不包括dbm

cx_Freeze不包括dbm
EN

Stack Overflow用户
提问于 2015-11-12 23:12:54
回答 1查看 455关注 0票数 1

有谁有适合我的程序的setup.py文件吗?我的整个程序是here。是否有任何一种dbm的导入?我已经尝试了很多东西来使我的exe工作。这是我最后一次尝试。

这是我用来将我的程序转换成一个exe文件的setup.py文件。

代码语言:javascript
复制
from cx_Freeze import setup, Executable

packages = []
for dbmodule in ['dbhash', 'gdbm', 'dbm', 'dumbdbm', 'gnu', 'ndbm', 'dumb',
                 'dbm.gnu', 'dbm.ndbm', 'dbm.dumb', 'gnudbm', 'ndbmdbm']:
    try:
        __import__(dbmodule)
    except ImportError:
        pass
    else:
        # If we found the module, ensure it's copied to the build directory.
        packages.append(dbmodule)
build_exe_options = {'packages': ['os','sys','shelve']}
setup(name='RockPaperScissors-V2',
      options = {"build_exe": build_exe_options},
      version='0.1',
      description='Classic game of Rock Paper Scissors',
      executables = [Executable("RockPaperScissorsV2.py")])

当我试图运行我的exe程序时,我会得到这个错误。

代码语言:javascript
复制
E:\Python3 Files\RockPaperScissors\build\exe.win32-3.4>RockPaperScissorsV2
Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27
, in <module>
    exec(code, m.__dict__)
  File "RockPaperScissorsV2.py", line 201, in <module>
  File "RockPaperScissorsV2.py", line 153, in start_game
  File "RockPaperScissorsV2.py", line 120, in intro
  File "C:\Python34\lib\shelve.py", line 239, in open
    return DbfilenameShelf(filename, flag, protocol, writeback)
  File "C:\Python34\lib\shelve.py", line 223, in __init__
    Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
  File "C:\Python34\lib\dbm\__init__.py", line 75, in open
    raise ImportError("no dbm clone found; tried %s" % _names)
ImportError: no dbm clone found; tried ['dbm.gnu', 'dbm.ndbm', 'dbm.dumb']
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-13 16:52:17

最后,经过多次测试,我找到了答案。其实很简单。我所要做的就是将dbm添加到转换文件中的包中。

代码语言:javascript
复制
from cx_Freeze import setup, Executable

build_exe_options = {'packages': ['dbm']}
setup(name='RockPaperScissors-V2',
      version='0.1',
      options = {"build_exe": build_exe_options},
      description='Classic game of Rock Paper Scissors',
      executables = [Executable("RockPaperScissorsV2.py")])
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33683188

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档