[英]cx_Freeze not including dbm
是否有人擁有適用於我的程序的setup.py文件? 我的整個程序在這里 。 反正有導入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']
最后,經過多次測試,我找到了答案。 實際上,這非常簡單。 我要做的就是將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")])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.