Python cx_冻结不包括dbm
是否有人拥有适用于我的程序的setup.py文件?我的整个计划都是。是否仍要导入一个dbm? 我尝试了很多方法来让我的exe工作。这只是我最后一次尝试 这是我用来将程序转换为exe文件的setup.py文件Python cx_冻结不包括dbm,python,Python,是否有人拥有适用于我的程序的setup.py文件?我的整个计划都是。是否仍要导入一个dbm? 我尝试了很多方法来让我的exe工作。这只是我最后一次尝试 这是我用来将程序转换为exe文件的setup.py文件 from cx_Freeze import setup, Executable packages = [] for dbmodule in ['dbhash', 'gdbm', 'dbm', 'dumbdbm', 'gnu', 'ndbm', 'dumb',
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程序时遇到此错误
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']
E:\Python3文件\RockPaperScissors\build\exe.win32-3.4>RockPaperScissors v2
回溯(最近一次呼叫最后一次):
文件“C:\Python34\lib\site packages\cx\u Freeze\initscripts\Console.py”,第27行
在里面
执行官(代码、指令)
文件“RockPaperScissorsV2.py”,第201行,在
文件“RockPaperScissorsV2.py”,第153行,在start_游戏中
文件“RockPaperScissorsV2.py”,第120行,在简介中
文件“C:\Python34\lib\shelve.py”,第239行,打开
返回DbfilenameShelf(文件名、标志、协议、写回)
文件“C:\Python34\lib\shelve.py”,第223行,在\uu init中__
Shelf.\uuuu init\uuuuu(self,dbm.open(文件名,标志),协议,写回)
文件“C:\Python34\lib\dbm\\uuuuu init\uuuuuu.py”,第75行,打开
引发导入错误(“未找到dbm克隆;尝试了%s”%\u个名称)
ImportError:未找到dbm克隆;已尝试['dbm.gnu','dbm.ndbm','dbm.dumb']
经过多次测试,我终于找到了答案。其实很简单。我所要做的就是将dbm
添加到convert文件中的包中
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")])
您也可以尝试冻结您的代码。@anon谢谢,我会尝试的。你知道dbm做什么吗??