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. 前端使用express+node实现接口模拟及websocket通讯

    简述如何使用node+express实现接口连接及入门websocket通讯.使用技术栈:node + express + typescript + websocket. 1.接口实现 这里描述前端如 ...

  2. EPS 转 pdf 在线

    EPS 转 pdf 在线网站 https://convertio.co/zh/eps-pdf/

  3. java带jar包的命令行运行

    运行有些java类需要第三方的jar包(lib),在用命令行运行时本人总结如下几个方法: 方法一.编译  javac -cp D:\lab\googleapi.jar Lab.java设置classp ...

  4. UIRecorder安装与使用

    继vue单元测试,将进行vue的e2e测试学习. 学习点: 安装uirecorder 用工具(UI Recorder)录制测试脚本 测试脚本的回放 本文意在安装UI Recorder,并且利用该工具进 ...

  5. linux内核编译与开发

    一.Linux内核简介linux kernel map: linux 系统体系结构: linux kernel体系结构: arm有7种工作模式,x86也实现了4个不同级别RING0-RING3,RIN ...

  6. 设计模式——原型模式(Prototype Pattern)

    原型模式:用原型实例制定创建对象的种类,并且通过拷贝这些原型创建新的对象. UML 图: 原型类: package com.cnblog.clarck; /** * 原型类 * * @author c ...

  7. (第六场)Heritage of skywalkert 【玄学】

    题目链接:https://www.nowcoder.com/acm/contest/144/J 标题:J.Heritage of skywalkert | 时间限制:1 秒 | 内存限制:256M s ...

  8. (转)理解YOLOv2训练过程中输出参数含义

    最近有人问起在YOLOv2训练过程中输出在终端的不同的参数分别代表什么含义,如何去理解这些参数?本篇文章中我将尝试着去回答这个有趣的问题. 刚好现在我正在训练一个YOLOv2模型,拿这个真实的例子来讨 ...

  9. 手机验证码免费10条\java、C#、html....

    使用互亿无线短信接口网址:http://www.ihuyi.com/. 首先第一步,进行注册 第二步:注册成功后进来的页面 第三步:实名认证 第四步:个人信息 等待认证成功后才能继续操作 第五步:进行 ...

  10. git报错error: src refspec refs/heads/master does not match any.

    $ git pusherror: src refspec refs/heads/master does not match any.error: failed to push some refs 出错 ...