KeyError: 'TCL_Library' 当我使用 cx_Freeze 时 [英] KeyError: 'TCL_Library' when I use cx_Freeze

查看:24
本文介绍了KeyError: 'TCL_Library' 当我使用 cx_Freeze 时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 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 FilesPython35-32	cl	cl8.6
set TK_LIBRARY=C:Program FilesPython35-32	cl	k8.6

您也可以在 setup.py 脚本中执行此操作:

You can also do that in the setup.py script:

os.environ['TCL_LIBRARY'] = r'C:Program FilesPython35-32	cl	cl8.6'
os.environ['TK_LIBRARY'] = r'C:Program FilesPython35-32	cl	k8.6'

setup([..])

<小时>

但我发现实际运行该程序不起作用.在 cx_freeze 邮件列表中提到了:

我已经研究过了,不,这不仅仅是简单的重新编译——否则早就完成了!:-)

I have looked into it already and no, it is not just a simple recompile -- or it would have been done already! :-)

它正在进行中,看起来需要一些努力.一些用于处理包中的扩展模块之类的代码正在跌倒——这可能会通过删除该代码和更好地解决强制将包放在 zip 文件之外(另一个需要的拉取请求被吸收).我下周和下周应该有时间进一步研究这一点.所以一切顺利我应该把年底前推出新版cx_Freeze.

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.

这篇关于KeyError: 'TCL_Library' 当我使用 cx_Freeze 时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆