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

时间:2018-04-16 09:05:03

标签: cmd executable python-3.6

我有一个运行完美的python代码我想将此代码转换为可执行文件。我正在使用python 3.6。

到目前为止,我能够将其转换并使其运行,但问题是当用户尝试运行.exe文件时, cmd 窗口会打开。

如何让cmd窗口隐藏不显示

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

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
    )

1 个答案:

答案 0 :(得分:0)

base=None更改为base="Win32GUI"