首页 > 解决方案 > cx_freeze - 如何更改对 lib 的引用

问题描述

使用 cx_freeze 构建 Python 应用程序。

from cx_Freeze import setup, Executable
_packages = []
_excludes = []
_include_files = [...]

buildOptions = dict(packages = _packages, enter code here`excludes = _excludes, include_files = _include_files, build_exe = '<app name>')

setup(name = '<app name>',
   version = <version>,
   description = '<description>',
   options = dict(build_exe = buildOptions),
      executables = [Executable('<app name>.py',
         targetName = '<app name>',
          icon = '<app name>.png')])

尝试在 Linux 上的 /usr/bin/ 中安装使用 cx_freeze 构建的应用程序,应用程序资源位于 /usr/share/ 中。

当然这会导致:

Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module name 'encodings'

Current thread 0x0... (most recent call first):...

我需要设置/更改 lib 文件夹的默认位置,但我一直无法弄清楚如何做到这一点。我完全有可能走在完全错误的轨道上。

我试图避免使用 bbfreeze。

标签: python-3.xcx-freeze

解决方案


在查看代码后,我相信我想做的事情是不可能的。'lib' 目录在 cx_freeze 中硬编码。


推荐阅读