将.py文件转换为exe时出错

时间:2017-01-31 16:08:10

标签: python tkinter tcl exe cx-freeze

当我尝试将.py文件转换为exe时,我在命令提示符下出现此错误:

[Errno 2] No such file or directory: 'C:\\Program Files\\Python35\\tcl\\tcl8.6'

这是我的setup.py文件代码:

from cx_Freeze import setup, Executable

import os
os.environ['TCL_LIBRARY'] = "C:\\Program Files\\Python35\\tcl\\tcl8.6"
os.environ['TK_LIBRARY'] = "C:\\Program Files\\Python35\\tcl\\tk8.6"

setup (name = 'CODAQ Beta', version = '0.1', description = 'Aerosol Data Visualization Environment', executables = [Executable("CODAQ.py")])

我听说我可能需要更改os.environ['TCL_LIBRARY']os.environ['TK_LIBRARY'],具体取决于我系统中tcl8.6tk.86的路径。关于如何做到这一点的任何提示?

1 个答案:

答案 0 :(得分:2)

找到解决方案:

tcl实际上是在Anaconda3:

这是我改变的代码:

from cx_Freeze import setup, Executable

import os
os.environ['TCL_LIBRARY'] = "C:\\Program Files\\Anaconda3\\tcl\\tcl8.6"
os.environ['TK_LIBRARY'] = "C:\\Program Files\\Anaconda3\\tcl\\tk8.6"

setup (name = 'CODAQ Beta', version = '0.1', description = 'Aerosol Data Visualization Environment', executables = [Executable("CODAQ.py")])