WARNING: Several hooks defined for module ‘win32ctypes.core‘. Please take care they do not conflict

问题:

python pyinstaller打包错误:

WARNING: Several hooks defined for module 'win32ctypes.core'. Please take care they do not conflict.

解决过程:

安装pypiwin32

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pypiwin32

依然报错,如下图所示:
在这里插入图片描述

解决办法:

最终发现是因为导包问题引起的,两个依赖库确实已经安装只是导入方式不同导致报错。

在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/weixin_32831351/article/details/111920888

猜你喜欢

转载自blog.csdn.net/weixin_47542175/article/details/114259934