使用cx_Freeze冻结Python应用程序时出错

时间:2017-03-16 21:34:47

标签: python python-3.x cx-freeze

我试图在Python 3.6中构建一个程序,但我一直在努力获得一个功能正常的.exe。打包脚本看起来像完成,但生成的程序会立即崩溃。即使使用早期版本的python 3,我也遇到过与py2exe和pyinstaller类似的问题,但是我能够从cx_freeze 5.0.1的可执行文件中得到以下错误:

Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x000019a0 (most recent call first):

之前已经提到过关于unix系统的搜索,但是我在Windows 10上这样做了吗?

这是包装脚本:

from cx_Freeze import setup, Executable
import os
os.environ['TCL_LIBRARY'] = "C:\\Program Files (x86)\\Python36-32\\tcl\\tcl8.6"
os.environ['TK_LIBRARY'] = "C:\\Program Files (x86)\\Python36-32\\tcl\\tk8.6"

# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages = [], excludes = [])

import sys
base = None
#'Win32GUI' if sys.platform=='win32' else None

executables = [
    Executable('WorkingScript.py', base=base, targetName = 'WorkingScript.exe', icon='IconSml.ico')]]
    includefiles=["Logo3.png", "Image4.png", "IconSml.ico"]

setup(name='WorkingScript',
      version = '0.9',
      description = 'This time around',
      options = dict(build_exe = buildOptions),
      executables = executables)

我的程序导入的唯一模块是tkinter,PIL,os,threading,csv和xml.dom。

0 个答案:

没有答案