cx_Freeze ModuleNotFoundError: No module named 'codecs'

cx_Freeze ModuleNotFoundError: No module named 'codecs'

正在尝试将 .py 文件转换为 .exe 尝试 运行 exe.win32-3.6 文件夹中的 .exe 文件时出现以下错误:

C:\Users\Aktan\Desktop\build\exe.win32-3.6>StatisticsCalculator.exe
Fatal Python error: Py_Initialize: unable to load the file system codec
Traceback (most recent call last):
  File "C:\Users\Aktan\AppData\Local\Programs\Python\Python36-32\lib\encodings\__init__.py", line 31, in <module>
ModuleNotFoundError: No module named 'codecs'

这是我的 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\tcl8.6"

base = None

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

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

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

我不知道它是否有帮助,但这是我在 python 程序中使用的模块:

import sqlite3
from math import pow, sqrt
from tkinter import Tk, Label, Listbox, END, Button, Message, messagebox
import matplotlib.pyplot as plt

我有 python 3.6.3,我正在 运行ning Windows 10。如有任何回复,我们将不胜感激。

这是 cx_Freeze 的一个已知问题,已在源代码中解决。不久将发布新版本 (5.1.1) 以解决该问题!