有谁有适合我的程序的setup.py文件吗?我的整个程序是here。是否有任何一种dbm的导入?我已经尝试了很多东西来使我的exe工作。这是我最后一次尝试。
这是我用来将我的程序转换成一个exe文件的setup.py文件。
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']发布于 2015-11-13 16:52:17
最后,经过多次测试,我找到了答案。其实很简单。我所要做的就是将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")])https://stackoverflow.com/questions/33683188
复制相似问题