Fix tcl/tk libs inclusion in tkinter with Python3.7 under MacOS

使用 Pyinstaller 打包时候报错

3027 ERROR: Tcl/Tk improperly installed on this system.
(lyj_venv) ➜ liyongjiandeMBP.lan [/Users/liyongjian/lyj] pyinstaller --windowed --onefile --clean --noconfirm ServenDigitsDrawV2.py
INFO: PyInstaller: 3.4
INFO: Python: 3.7.
INFO: Platform: Darwin-18.5.-x86_64-i386-64bit
INFO: wrote /Users/liyongjian/lyj/ServenDigitsDrawV2.spec
INFO: UPX is not available.
INFO: Removing temporary files and cleaning cache in /Users/liyongjian/Library/Application Support/pyinstaller
INFO: Extending PYTHONPATH with paths
['/Users/liyongjian/lyj', '/Users/liyongjian/lyj']
INFO: checking Analysis
INFO: Building Analysis because Analysis-.toc is non existent
INFO: Initializing module dependency graph...
INFO: Initializing module graph hooks...
INFO: Analyzing base_library.zip ...
INFO: running Analysis Analysis-.toc
INFO: Caching module hooks...
INFO: Analyzing /Users/liyongjian/lyj/ServenDigitsDrawV2.py
INFO: Loading module hooks...
INFO: Loading module hook "hook-_tkinter.py"...
ERROR: Tcl/Tk improperly installed on this system.
INFO: Loading module hook "hook-encodings.py"...
INFO: Loading module hook "hook-xml.py"...
INFO: Loading module hook "hook-pydoc.py"...
INFO: Looking for ctypes DLLs
INFO: Analyzing run-time hooks ...
INFO: Including run-time hook 'pyi_rth__tkinter.py'
INFO: Looking for dynamic libraries
INFO: Looking for eggs
INFO: Using Python library /Library/Frameworks/Python.framework/Versions/3.7/Python
INFO: Warnings written to /Users/liyongjian/lyj/build/ServenDigitsDrawV2/warn-ServenDigitsDrawV2.txt
INFO: Graph cross-reference written to /Users/liyongjian/lyj/build/ServenDigitsDrawV2/xref-ServenDigitsDrawV2.html
INFO: checking PYZ
INFO: Building PYZ because PYZ-.toc is non existent
INFO: Building PYZ (ZlibArchive) /Users/liyongjian/lyj/build/ServenDigitsDrawV2/PYZ-.pyz
INFO: Building PYZ (ZlibArchive) /Users/liyongjian/lyj/build/ServenDigitsDrawV2/PYZ-.pyz completed successfully.
INFO: checking PKG
INFO: Building PKG because PKG-.toc is non existent
INFO: Building PKG (CArchive) PKG-.pkg
INFO: Building PKG (CArchive) PKG-.pkg completed successfully.
INFO: Bootloader /Users/liyongjian/lyj/lyj_venv/lib/python3./site-packages/PyInstaller/bootloader/Darwin-64bit/runw
INFO: checking EXE
INFO: Building EXE because EXE-.toc is non existent
INFO: Building EXE from EXE-.toc
INFO: Appending archive to EXE /Users/liyongjian/lyj/dist/ServenDigitsDrawV2
INFO: Fixing EXE for code signing /Users/liyongjian/lyj/dist/ServenDigitsDrawV2
INFO: Building EXE from EXE-.toc completed successfully.
INFO: checking BUNDLE
INFO: Building BUNDLE because BUNDLE-.toc is non existent
INFO: Building BUNDLE BUNDLE-.toc
INFO: moving BUNDLE data files to Resource directory

执行的时候报错

➜ liyongjiandeMBP.lan [/Users/liyongjian] /Users/liyongjian/lyj/dist/ServenDigitsDrawV2 ; exit;
Traceback (most recent call last):
File "PyInstaller/loader/rthooks/pyi_rth__tkinter.py", line , in <module>
FileNotFoundError: Tcl data directory "/var/folders/f9/6m090zhs6w55rmbmhkmpff440000gn/T/_MEITVlJln/tcl" not found.
[] Failed to execute script pyi_rth__tkinter [进程已完成]

解决办法:

在文件中增加

 and 'Python' not in path_to_tcl
PyInstaller/hooks/hook-_tkinter.py
@@ -, +, @@ def _find_tcl_tk(hook_api): # _tkinter depends on Tcl/Tk compiled as frameworks.
path_to_tcl = bins[][]
- if 'Library/Frameworks' in path_to_tcl:
+ if 'Library/Frameworks' in path_to_tcl and 'Python' not in path_to_tcl:

参考链接:https://github.com/pyinstaller/pyinstaller/pull/3830
               https://stackoverflow.com/questions/51847801/pyinstaller-app-not-opening-on-mac

【解决】MacOS下 Python3.7 使用 pyinstaller 打包后执行报错 Failed to execute script pyi_rth__tkinter的更多相关文章

  1. moviepy应用pyinstaller打包后执行报错AttributeError: module audio/video.fx.all has no attribute fadein、crop

    专栏:Python基础教程目录 专栏:使用PyQt开发图形界面Python应用 专栏:PyQt入门学习 老猿Python博文目录 在开发moviepy的Python程序使用pyinstaller打包后 ...

  2. 【Python】pyinstaller打包运行报错failed to execute script main

    前言 最近用pyinstaller打包的时候一直报"failed to execute script main". 最终使用"pyinstaller --hidden-i ...

  3. Pyinstaller 打包exe 报错 "failed to execute script XXX"的一种解决方案

    最近用PyQt5写了一个界面小程序,需要打包成exe给到其他windows上使用,一开始使用python 3.7 64位,用pyinstaller打包exe,在64位机上运行正常. 但是目标电脑是32 ...

  4. vue 使用webpack打包后路径报错以及 alias 的使用

    一.vue 使用webpack打包后路径报错(两步解决) 1. config文件夹 ==> index.js ==> 把assetsPublicPath的 '/ '改为 './' 2. b ...

  5. 解决Pyqt打包后运行报错:应用程序无法启动 因为程序的并行配置不正确

    做了一个生成二维码的小程序:http://www.cnblogs.com/dcb3688/p/4241048.html 直接运行脚本没问题,用pyinstaller打包后再运行就直接报错了: 应用程序 ...

  6. 【Python】解决使用pyinstaller打包Tkinker程序报错问题

    问题描述 使用pyinstaller打包使用Tkinter编写的控制台程序,出现报错 15793 INFO: Adding Microsoft.Windows.Common-Controls to d ...

  7. vue项目打包后运行报错400如何解决

    昨天一个Vue项目打包后,今天测试,发现无论localhost还是服务器上都运行不了,报错如下: Failed to load resource: the server responded with ...

  8. 【spring cloud】在spring cloud服务中,打包ms-core失败,报错Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.4.RELEASE:repackage (default) on project

    在spring cloud服务中,有一个ms-code项目,只为所有的微服务提供核心依赖和工具类,没有业务意义,作为核心依赖使用.所以没有main方法,没有启动类. 在spring cloud整体打包 ...

  9. vue打包后接口报错

    最近自己和朋友做了一个小的项目,用的是vue3.x版本,本地dev运行的时候接口什么的都是正常的,但是build打包后本地使用anywhere启动一个本地服务的时候发现接口报错405状态,发布到线上接 ...

随机推荐

  1. show与ShowDialog substring

    substring public String substring(int beginIndex, int endIndex) 返回一个新字符串,它是此字符串的一个子字符串.该子字符串从指定的 beg ...

  2. 尝试VS插件

    从试用vs2013开始,ide变得越来越智能,但是vs2013总是会出一些莫名其妙的问题,导致编译不成功,不能跟vs2010共享等等.于是由再次回到vs2010. 现在vs2015的update1更新 ...

  3. 我的SublimeText配置

    我的SublimeText改键 [ /** * 我的改键 */ // f1控制中心:f2快速查找:f3查找下一个: { "keys": ["f1"], &quo ...

  4. log4j2简单使用

    http://www.cnblogs.com/lzb1096101803/p/5796849.html 如果是基于的slf4j,看这篇文章去配置 http://blog.csdn.net/neosmi ...

  5. PrintDocument打印、预览、打印机设置和打印属性的方法(较完整) .

    private void Form1_Load(object sender, System.EventArgs e) { //获取或设置一个值,该值指示是否发送到文件或端口 printDocument ...

  6. 简单记录一下http请求的7个步骤

    1.建立TCP连接 2.客户端发送请求命令 3.客户端发送请求头信息 4.服务端应答请求,返回版本号和状态码 5.服务端应答头信息 6.服务端向客户端发送数据 7.服务器关闭TCP连接(Connect ...

  7. dedecms 权重排序问题

    isweight='y' orderway='asc'  orderby='weight'  依次进入根目录>dede 找到打开文件 album_edit.php   //找到更新数据库的SQL ...

  8. [19/03/15-星期五] 常用类_String类&StringBuilder和StringBuffer类

    一.基本概念 String 类对象代表不可变的Unicode字符序列,因此我们可以将String对象称为“不可变对象”. 那什么叫做“不可变对象”呢?  指的是对象内部的成员变量的值无法再改变.Str ...

  9. 使用ToString方法格式化日期

    实现效果: 关键知识: Environment类的NewLine属性  //用于获取为此环境定义的换行字符串,程序执行过程中方便对字符串进行换行 Environment类的EXIT方法     //用 ...

  10. Strtus2框架使用HttpServletResponse响应数据

    -----------------------------------------------------------------------------------------jsp-------- ...