とのことなので試しにHello World的なものを作ってみた。
■用意したもの
Python 3.3.0
cx_Freeze4.3.3
■ソース
#sample.py
from tkinter import * from tkinter.messagebox import * root = Tk() n = IntVar() n.set(0) func_table = (showinfo, showwarning, showerror, askquestion, askokcancel, askyesno, askretrycancel) name_table = ('showinfo', 'showwarning', 'showerror', 'askquestion', 'askokcancel', 'askyesno', 'askretrycancel') def message_box(): func = func_table[n.get()] func(title = 'about', message = u'Hello World!') for m, name in enumerate(name_table): Radiobutton(root, text = name, value = m, variable = n).pack(anchor='w') Button(root, text = "Open message box", command = message_box).pack() root.mainloop() |
んで、とりあえずビルドするために、
#setup.py
import sys from cx_Freeze import setup, Executable base = None if sys.platform == 'win32' : base = 'Win32GUI' exe = Executable(script = 'sample.py', base = base) 2 setup(name = 'sample', version = '0.1', description = 'converter', executables = [exe] ) |
ここまで準備を終え、setup.py buildするとexeファイルは出来上がるのだが
いざ実行すると
---------------------------
cx_Freeze: Python error in main script (traceback unavailable)
---------------------------
Cannot import traceback module.
Exception: cannot import name MAXREPEAT
Original Exception: cannot import name MAXREPEAT
---------------------------
OK
---------------------------
が出る・・・
調べてみたところPython 3.3.0のバグだったみたい。
3.3.5にアップグレードしたらちゃんと動きましたとさ。
# 原因を追究するのに半日かかってしまったorz
0 件のコメント:
コメントを投稿