完美解决pyinstaller打包报错找不到依赖pypiwin32或pywin32-ctypes的错误
作者:一笑程序猴 时间:2023-07-31 10:06:37
报错信息
最近闲来无事,用python的tkinter库开发了一款带日程提醒的万年历桌面程序。在程序开发结束开始打包时,却发现一直报错
PyInstaller cannot check for assembly dependencies.
Please install PyWin32 or pywin32-ctypes.
pip install pypiwin32
但是运行pip install pypiwin32时却提示两个库都已经安装过了
可是当再运行打包脚本时就是死活无法打包,就是提示缺少上面两个依赖库。
各种度娘发现都没有遇到类似奇葩情况的。
于是决定自行解决,首先根据错误关键词到pyinstaller的源码中去检索报错位置。
最终发现是因为导包问题引起的,两个依赖库确实已经安装只是导入方式不同导致报错。
解决方案
在python安装路径下找到Lib/site-packages/Pyinstaller目录下有个compat.py文件定位到212行
源码如下:
if is_win:
try:
from win32ctypes.pywin32 import pywintypes # noqa: F401
from win32ctypes.pywin32 import win32api
except ImportError:
xxxx
xxxx
做如下修改:将两个from改为import
if is_win:
try:
# from win32ctypes.pywin32 import pywintypes # noqa: F401
# from win32ctypes.pywin32 import win32api
import pywintypes
import win32api
except ImportError:
xxxx
xxxx
然后再重新运行打包脚本,打包成功
来源:https://blog.csdn.net/lixiaosenlin/article/details/103974607
标签:pyinstaller,打包报错,pypiwin32
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
使用Python求解最大公约数的实现方法
2021-03-20 07:58:51
简单介绍Python中的struct模块
2023-09-22 16:27:01
python实现拼图小游戏
2023-05-14 14:54:15
![](https://img.aspxhome.com/file/2023/2/76702_0s.jpg)
python贪吃蛇核心功能实现下
2021-08-23 00:32:37
![](https://img.aspxhome.com/file/2023/8/124148_0s.png)
小学生也能看懂的Golang异常处理recover panic
2024-02-08 20:32:36
![](https://img.aspxhome.com/file/2023/2/107302_0s.jpg)
概述javascript在Google IE中的调试技巧
2023-08-08 11:50:29
![](https://img.aspxhome.com/file/2023/8/55928_0s.jpg)
MySQL中可为空的字段设置为NULL还是NOT NULL
2024-01-13 14:38:26
![](https://img.aspxhome.com/file/2023/0/102390_0s.png)
python获得两个数组交集、并集、差集的方法
2022-08-12 18:37:31
从云数据迁移服务看MySQL大表抽取模式的原理解析
2024-01-24 01:45:41
![](https://img.aspxhome.com/file/2023/9/107899_0s.png)
python3的pip路径在哪
2023-01-27 14:15:39
Mysql查询以某"字符串"开头的查询方式
2024-01-24 21:05:19
python实现通讯录系统
2023-06-12 20:57:50
![](https://img.aspxhome.com/file/2023/1/81791_0s.jpg)
jmeter正则表达式的使用
2022-08-10 01:10:42
![](https://img.aspxhome.com/file/2023/2/86872_0s.png)
python3利用Dlib19.7实现人脸68个特征点标定
2021-05-05 19:13:06
![](https://img.aspxhome.com/file/2023/4/76034_0s.jpg)
python 巡检脚本的项目实践
2023-10-06 11:54:15
![](https://img.aspxhome.com/file/2023/6/109396_0s.png)
Vue前后端不同端口的实现方法
2024-05-28 16:03:44
Python数字图像处理基础直方图详解
2021-02-12 08:21:55
![](https://img.aspxhome.com/file/2023/9/124339_0s.png)
mysql添加索引方法详解(Navicat可视化加索引与sql语句加索引)
2024-01-24 22:32:37
![](https://img.aspxhome.com/file/2023/3/126253_0s.png)
Pycharm修改python路径过程图解
2022-10-27 15:57:26
![](https://img.aspxhome.com/file/2023/8/101058_0s.png)
python实现的简单文本类游戏实例
2022-10-22 02:32:51