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. js动画杂记

    在画布上做动画 方法有 setIntervel(function(){},time); setTimeout(function(){},time); 新方法 window.requestAnimati ...

  2. Python爬虫《Python网络爬虫相关基础概念》

    引入 之前在授课过程中,好多同学都问过我这样的一个问题:为什么要学习爬虫,学习爬虫能够为我们以后的发展带来那些好处?其实学习爬虫的原因和为我们以后发展带来的好处都是显而易见的,无论是从实际的应用还是从 ...

  3. axios 发 post 请求,后端接收不到参数的解决方案

    问题场景 场景很简单,就是一个正常 axios post 请求: axios({ headers: { 'deviceCode': 'A95ZEF1-47B5-AC90BF3' }, method: ...

  4. arcgis版接合图表5.2 免费软件,支持国家2000坐标系,ArcGIS10.0,ArcGIS10.1,ArcGIS10.2都可以使用

    下载地址:http://files.cnblogs.com/gisoracle/jionmap52.rar 1.      国家2000,西安80,北京54.坐标系的接合图表生成.根据经纬度范围,坐标 ...

  5. SQL Server 2012安装配置(Part2 )

    2 服务器安装 运行安装程序后,首先进入 SQL Server 安装中心.选择左侧导航树中的"安装"菜单项. 图2-1 SQL Server 安装中心 在右侧菜单中点击" ...

  6. OpenGL中的数据——Buffer

    OpenGL中主要包括了两种数据——Buffer和Texture. Buffer用于储存线性数无类型据块,可以看成普通的内存块,而Texture则用于储存多维数据,一般储存图像或者其他数据. Buff ...

  7. 利物浦VS曼城,罗指导的先手与工程师的后手

      本想『标题党』一下的,『高速反击遭遇剧情反转,巴西人力挽狂澜绝处逢生!』这种好像看起来比较厉害的标题似乎在大战之后的第五天已显得不合适了. /不害臊    反正晚了,干脆写点能够引起讨论.并且在未 ...

  8. IOS 蓝牙(GameKit、Core Bluetooth)

    GameKit的蓝牙开发注意 ● 只能用于iOS设备之间的连接 ● 只能用于同一个应用程序之间的连接 ● 最好别利用蓝牙发送比较大的数据 /* 关于蓝牙的数据传输  1. 一次性传送,没有中间方法,所 ...

  9. python 用cookie模拟登陆网站

    import re import requests def get_info(url): headers = { "Cookie" :"***************** ...

  10. ShellSort uva

    ShellSort He made each turtle stand on another one's back And he piled them all up in a nine-turtle ...