问题描述
当我使用 cx_Freeze
时,在构建我的pygame程序时遇到了keyerror KeyError:‘TCL_Library’
。为什么我会得到它以及如何解决它?
When I use cx_Freeze
I get a keyerror KeyError: 'TCL_Library'
while building my pygame program. Why do I get this and how do I fix it?
我的setup.py如下:
My setup.py is below:
from cx_Freeze import setup, Executable
setup(
name = "Snakes and Ladders",
version = "0.9",
author = "Adam",
author_email = "Omitted",
options = {"build_exe": {"packages":["pygame"],
"include_files": ["main.py", "squares.py",
"pictures/Base Dice.png", "pictures/Dice 1.png",
"pictures/Dice 2.png", "pictures/Dice 3.png",
"pictures/Dice 4.png", "pictures/Dice 5.png",
"pictures/Dice 6.png"]}},
executables = [Executable("run.py")],
)
推荐答案
您可以通过手动设置环境变量来解决此错误:
You can work around this error by setting the environment variables manually:
set TCL_LIBRARY=C:\Program Files\Python35-32\tcl\tcl8.6
set TK_LIBRARY=C:\Program Files\Python35-32\tcl\tk8.6
您也可以在 setup.py
脚本中执行以下操作:
You can also do that in the setup.py
script:
os.environ['TCL_LIBRARY'] = r'C:\Program Files\Python35-32\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Program Files\Python35-32\tcl\tk8.6'
setup([..])
但是我发现实际运行该程序无效。在:
它正在进行中,似乎需要一些努力。
代码中有一些处理诸如
包中的扩展模块之类的代码的问题-可以通过删除该代码和
将包强制压缩到zip文件之外来更好地解决(另一个需要
的拉取请求)。我应该在下周和
之后的下周有一些时间进行进一步研究。所以所有的事情都很好,我应该在年底之前发布新版本的cx_Freeze
a。
It is in progress and it looks like it will take a bit of effort. Some of the code in place to handle things like extension modules inside packages is falling over -- and that may be better solved by dropping that code and forcing the package outside the zip file (another pull request that needs to be absorbed). I should have some time next week and the week following to look into this further. So all things working out well I should put out a new version of cx_Freeze before the end of the year.
您还有更多的运气...
But perhaps you have more luck ... Here's the bug report.
这篇关于我使用cx_Freeze时出现KeyError:“ TCL_Library”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!