如何将 python 代码转换成可执行文件

how to convert python code into executable file

我有一个 python 代码 运行 完美现在我想将这段代码转换成 可执行文件 。我正在使用 python 3.6.

直到现在我才能够将它转换成 运行 但问题是当用户尝试 运行 .exe 文件时 cmd window 已打开。

我怎样才能让命令window隐藏不显示

下面的代码是创建包含转换后的可执行文件的构建文件夹。

setup.py

import cx_Freeze
import sys
import os
import matplotlib

#os.environ['TCL_LIBRARY'] = "C:\LOCAL_TO_PYTHON\Python35-32\tcl\tcl8.6"
#os.environ['TK_LIBRARY'] = "C:\LOCAL_TO_PYTHON\Python35-32\tcl\tk8.6"


os.environ['TCL_LIBRARY'] = "C:\EXECUTABLE_PROGRAMS\Python3.6\tcl\tcl8.6"
os.environ['TK_LIBRARY'] = "C:\EXECUTABLE_PROGRAMS\Python3.6\tcl\tk8.6"


base = None

if sys.platform == 'win32':
    base='Win32GUI'

executables = [cx_Freeze.Executable("myPDFviewer.py",base=None)]

cx_Freeze.setup(
    name = "this is a test",
    options = {"build_exe": {"packages":["numpy"],}},
    version = "0.01",
    descriptions = "Trying to get this to work",
    executables = executables
    )

base=None更改为base="Win32GUI"