cx_freeze可执行文件 - Py_Initialize:无法加载文件系统编解码器

时间:2018-05-30 08:18:02

标签: python windows cx-freeze

我正在使用cx_freeze将我的Python脚本打包为独立的可执行文件。 exe在包装好的机器上正常运行(使用python 3.5和所有相关软件包)。

但是当我将创建的文件夹cx_freeze复制到另一台机器时,我收到了这个错误: enter image description here

我的cx_freeze脚本:

import sys
import numpy
import os.path
from cx_Freeze import setup, Executable

os.environ['TCL_LIBRARY'] = r'C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\tcl\tk8.6'


setup(
    name = "DocSum",
    version = "1.0",
    options = {"build_exe": {"packages":["idna","asyncio", "encodings","numpy", "jinja2.ext"]}},
    description = "DocSumRESTfulServer",
    executables = [Executable("DocSumRESTfulServer.py", base = None)]
    )

任何想法可能是什么原因?我认为exe应该是一个独立的(在没有python的机器上运行)。我错了吗?

感谢。

2 个答案:

答案 0 :(得分:0)

似乎并非所有依赖项都已成功编译。 如果您想要一个独立的可执行文件,我建议 pyinstaller

然后点击安装它:

pyinstaller.exe --onefile  yourFile.py

--onefile标志用于将所有内容打包到单个可执行文件中。您的可执行文件可以在 dist 文件夹中找到。

你也可以尝试这个site

答案 1 :(得分:0)

我有同样的问题。最后,我发现我还需要复制com.android.tools.build:gradle:3.5.2python37.dll目录。 如果exe,dll和目录位于同一目录中,则可以正常工作。

我也想拥有一个exe。

相关问题