不包括dbm的cx冻结

2024-05-23 14:15:23 发布

您现在位置:Python中文网/ 问答频道 /正文

有人有吗设置.py对我的程序有用的文件?我的整个程序是here。有什么方法可以导入一个dbm吗? 为了使我的exe能正常工作,我做了很多事情。这只是我最后一次尝试。在

这是设置.py文件我用来把我的程序变成一个exe文件。在

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程序时遇到这个错误。在

^{pr2}$

Tags: 文件pygnuimportbuild程序packagessetup
1条回答
网友
1楼 · 发布于 2024-05-23 14:15:23

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

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")])

相关问题 更多 >