以下に再現した状況を書きますので、小学生に説明する様な気概で丁寧に対処法を教えて頂けませんでしょうか。指示の通りに操作し解決した場合、少ないですが500ポイントを送付させて頂きます。
環境:Windows7(54bit)/Python 3.1.1 Windows x86/cx_Freeze Windows Installer (Python 3.1)
Python及びcx_FreezeのインストールディレクトリはC:\Python31。
exe化対象のスクリプトではtkinterをtkという名前でインポートしています。
以下cmd操作。
cd C:\Python31\Scripts
cxfreeze script.py
以上の操作でバイナリ生成までは完了します。
しかし、exeファイルの実行時エラーが発生してしまいます。
C:\Python31\Scripts\dist>script.exe
Traceback (most recent call last):
File "C:\Python31\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 2
7, in <module>
exec(code, m.__dict__)
File "script.py", line 9, in <module>
File "C:\Python31\lib\tkinter\__init__.py", line 38, in <module>
from tkinter import _fix
ImportError: cannot import name _fix
_fixモジュールの読み込みに失敗している様ですが、対象方法がイマイチ解りません。ご教授お願い致します。
1.cmd操作を次のように変更して、実行します。青字部分が追加する文字です。
cd C:\Python31\Scripts
cxfreeze script.py --include-modules tkinter._fix
2.できたexeを実行します。
原因:cxfreezeなどでは、自動でのincludeが失敗することが多いため。明示してincludeすればエラーは消えます。
ありがとうございます。
回答頂いた通りの作業で無事に実行する事ができました。
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
{C:\Python31\Scripts\dist\tcl} C:/Python31/Scripts/dist/tcl8.5 C:/Python31/S
cripts/lib/tcl8.5 C:/Python31/Scripts/lib/tcl8.5 C:/Python31/lib/tcl8.5 C:/Pytho
n31/Scripts/library C:/Python31/library C:/Python31/tcl8.5.2/library C:/tcl8.5.2
/library
実行時上記の様なエラーが出たので、C:\Python31\Scripts\dist内にC:\Python31\tcl内のtcl8.5フォルダ及びtk8.5フォルダをコピーして挿入した所、問題なく実行できるようになりました。
上記エラーへの対処方法はこれで良かったのかは気になるところですが、とかく無事に実行できたので良かったです。
ありがとうございました。