简体   繁体   English

了解已知错误的修复:cx_Freeze & Python 3.7

[英]Understanding the fix for the known bug: cx_Freeze & Python 3.7

I have been trying to create a standalone GUI app for Mac OSX based on a python 3 script (version 3.7).我一直在尝试基于 python 3 脚本(版本 3.7)为 Mac OSX 创建一个独立的 GUI 应用程序。 The .py script works perfectly when launched directly from the terminal.直接从终端启动时,.py 脚本可以完美运行。 However this is for my father that needs assistance when downloading a .jpg, so he needs a simple double click app.然而,这是给我父亲下载 .jpg 时需要帮助的,所以他需要一个简单的双击应用程序。

Unfortunately all the tools I try to use seem to have known bugs with the modules I'm using ( py2App = openpyxl / pyinstaller = tkinter ).不幸的是,我尝试使用的所有工具似乎都有我正在使用的模块的已知错误( py2App = openpyxl / pyinstaller = tkinter )。 The one I'm trying to use now is cx_Freeze.我现在尝试使用的是 cx_Freeze。

However there is again a know bug with Python 3.7 described然而,描述了 Python 3.7 的已知错误

I've been trying to fix this on my mac OSX machine but cannot find the file that is being referred to (on this GIT-hub , the code linked by the first post hereabove).我一直试图在我的 mac OSX 机器上解决这个问题,但找不到被引用的文件(在这个 GIT-hub 上,上面第一篇文章链接的代码)。

I would like to fix this bug, but I would also like to understand why this is happening to increase my knowledge of both python and creating standalone apps.我想修复这个错误,但我也想了解为什么会发生这种情况,以增加我对 Python 和创建独立应用程序的了解。

Unfortunately, I'm not good enough to understand how to fix it by reading the GIT-hub posts (as they are directed to Windows systems and I do not find the files), nor why this bug occurs.不幸的是,我不够好,无法通过阅读 GIT-hub 帖子来了解如何修复它(因为它们是针对 Windows 系统的,而我没有找到这些文件),也不了解为什么会出现此错误。

Thanks in advance for your help.在此先感谢您的帮助。

for info, here is a copy of the terminal output when launching the created executable:有关信息,这是启动创建的可执行文件时终端输出的副本:

/Users/USER_NAME/Desktop/Python/DAD_PROJECT/build/exe.macosx-10.9-x86_64-3.7/PROJECT_NAME ; exit;
MacBook-Pro-de-USER_NAME:~ USER_NAME$ /Users/USER_NAME/Desktop/Python/DAD_PROJECT/build/exe.macosx-10.9-x86_64-3.7/PROJECT_NAME ; exit;
Fatal Python error: initfsencoding: unable to load the file system codec
ImportError: invalid flags 1545637508 in 'encodings'

Current thread 0x00007fff98191380 (most recent call first):
Abort trap: 6
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Opération terminée]

EDIT and for good measure, my setup.py file as well:编辑和更好的措施,我的 setup.py 文件以及:

Please note that this was automatically generated on my Mac using cxfreeze-quickstart as advised on cx-freeze.readthedocs请注意,这是根据cx-freeze.readthedocs 上的建议使用 cxfreeze-quickstart 在我的 Mac 上自动生成的

from cx_Freeze import setup, Executable

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

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

executables = [
    Executable('PROJECT_NAME.py', base=base, targetName = 'PROJECT_NAME')
]

setup(name='PROJECT_NAME',
      version = 'DAD_PROJECT',
      description = 'Project for my dad',
      options = dict(build_exe = buildOptions),
      executables = executables)

To find the path to the freezer.py file you need to modify, run the following in a Python console:要查找您需要修改的freezer.py文件的路径,请在 Python 控制台中运行以下命令:

from cx_Freeze import freezer
print(freezer.__file__)

Modify then this file according to this commit of the cx_Freeze repository, which means remove the red lines annotated with - and add the green lines annotated with + .然后根据cx_Freeze存储库的此提交修改此文件,这意味着删除用-注释的红线并添加用+注释的绿线。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM