2017-06-12 13 views
0

私はPythonスクリプトから実行ファイルを作成しようとしています。私はWindows 7、cx_freeze 5.0.2、Python 3.6を使用しています。cx_freeze Tkinter 'モジュールが見つかりません'

私はTkinterのが通常のライブラリに含まれていない、あなたは、次の2行に似た何かを追加する必要があることを知っている:3.6と私の場所にあるため、もちろん除いて

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

を、しかし、私は」することができますtはアナコンダ3.6

私は

import sys 
from cx_Freeze import setup, Executable 

# Dependencies are automatically detected, but it might need fine tuning. 
build_exe_options = {"packages": ["os"]} 

# GUI applications require a different base on Windows (the default is for a 
# console application). 
base = None 
if sys.platform == "win32": 
    base = "Win32GUI" 

setup( name = "McCabe-Thiele", 
     version = "0.1", 
     description = "My GUI application!", 
     options = {"build_exe": build_exe_options}, 
     executables = [Executable("GUI.py", base=base)]) 

のsetup.pyと呼ばれる次のファイルを作成し、python setup.py bdist_msiでCMDラインから実行してそのディレクトリを見つけます。

正常にインストールされたdistを正常に作成します。

しかし、私は、次のエラーが発生した.exeファイルを実行すると:

ModuleNotFoundError: no module named 'tkinter' 

は、3行目に、この

答えて

0

を持つ任意の助けを事前にいただきありがとうございます,"includes":["tkinter"]

依存関係を自動的にある追加検出されましたが、微調整が必​​要な場合があります。

私は python setup.py build

質問からコードを更新して、それを実行したときにそれは私のために働い

build_exe_options = {"packages": ["os"],"includes":["tkinter"]} 

import sys 
from cx_Freeze import setup, Executable 

# Dependencies are automatically detected, but it might need fine tuning. 
build_exe_options = {"packages": ["os"],"includes":["tkinter"]} 

# GUI applications require a different base on Windows (the default is for a 
# console application). 
base = None 
if sys.platform == "win32": 
    base = "Win32GUI" 

setup( name = "McCabe-Thiele", 
     version = "0.1", 
     description = "My GUI application!", 
     options = {"build_exe": build_exe_options}, 
     executables = [Executable("GUI.py", base=base)]) 
関連する問題