LoginSignup
11
10

More than 5 years have passed since last update.

tkinterを使ったアプリケーションをcx_freezeで実行ファイルにする

Posted at

cx_freezeではまったのでメモ。環境はwindow7(64bit)、pythonはPython 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32です。

setup.py

setup.py のサンプル。

setup.py
import sys

from cx_Freeze import setup, Executable

base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(
        name = "foo",
        version = "0.1",
        description = "foo",
        executables = [Executable("foo.py", base = base)])

コマンドラインから、

python setup.py build

でexeが作成できます。

Tclのライブラリが見つからないエラーが出た場合の対処方法。

_tkinter.TclError: Can't find a usable init.tcl in the following directories:
C:/home/workspace/tawami/software/lib/tcl8.5 C:/lib/tcl8.5 C:/lib/tcl8.5 C:/library C:/library C:/tcl8.5.10/library C:/tcl8.5.10/library

環境変数 TCL_LIBRARY をC:\Python27\tcl\tcl8.5、TK_LIBRARY を C:\Python27\tcl\tk8.5 等、自分の環境に合わせたパスに設定する。

バージョンコンフリクトのエラーが出たときの対象方法

version conflict for package "Tcl": have 8.5.10, need exactly 8.5.2

C:\Python27\tcl\tcl8.5\init.tclとc:/lib/tk8.5/tk.tclのpackage require -exact Tcl 8.5.2をコメントアウトする。

11
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
10