使用cx_Freeze冻结Python应用程序时出错
我试图用Python3.6构建一个程序,但我一直在努力获得一个functional.exe。打包脚本看起来已经完成,但生成的程序立即崩溃。即使在使用早期版本的python 3时,py2exe和pyinstaller也存在类似的问题,但我能够从cx_freeze 5.0.1的可执行文件中得到以下错误:使用cx_Freeze冻结Python应用程序时出错,python,python-3.x,cx-freeze,Python,Python 3.x,Cx Freeze,我试图用Python3.6构建一个程序,但我一直在努力获得一个functional.exe。打包脚本看起来已经完成,但生成的程序立即崩溃。即使在使用早期版本的python 3时,py2exe和pyinstaller也存在类似的问题,但我能够从cx_freeze 5.0.1的可执行文件中得到以下错误: Fatal Python error: Py_Initialize: unable to load the file system codec ModuleNotFoundError: No mod
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系统中提到过搜索,但我是在Windows10上做的
以下是打包脚本:
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。您使用的是哪一版本的cx\U freeze?在虚拟环境中使用cx_freeze时,我也遇到了同样的问题。通过使用
python-mvenv
而不是virtualenv
修复了它。无论如何,这个问题现在应该已经解决了,请参阅Bitbucket上的问题:这是5.0.1,尽管我也尝试过5.0,但没有运气。我最终设法让PyInstaller与Python3.4一起工作,所以现在就可以了?在虚拟环境中使用cx_freeze时,我也遇到了同样的问题。通过使用python-mvenv
而不是virtualenv
修复了它。无论如何,这个问题现在应该已经解决了,请参阅Bitbucket上的问题:这是5.0.1,尽管我也尝试过5.0,但没有运气。我最终设法让PyInstaller与Python3.4一起工作,所以现在就可以了。