Python 3.13.5中ctypes导入报错、tkinter DLL加载失败及重装旧版本异常的问题求助
Python 3.13.5中ctypes导入报错、tkinter DLL加载失败及重装旧版本异常的问题求助
大家好,今天我安装了Python 3.13.5后,项目运行和版本回滚都遇到了一堆棘手的问题,想请各位帮忙排查一下:
1. ctypes导入触发AttributeError
之前用旧版本Python时,带ctypes的项目运行完全正常,但升级到3.13.5后,运行项目直接报错:
Traceback (most recent call last): File "C:\Users\SomePerson\PycharmProjects\PYTHON\Test.py", line 134, in <module> import ctypes File "C:\Users\SomePerson\AppData\Local\Programs\Python\Python313\Lib\ctypes\__init__.py", line 157, in <module> class py_object(_SimpleCData): ...<5 lines>... return "%s(<NULL>)" % type(self).__name__ AttributeError: class must define a '_type_' attribute
这个错误完全超出我的预期,之前从未碰到过类似情况。
2. tkinter DLL加载失败
紧接着我试了另一个仅依赖tkinter的项目,我非常确定安装Python 3.13.5时勾选了“Install Tk/Tcl”相关选项,但运行时还是弹出了导入错误:
Traceback (most recent call last): File "C:\Users\SomePerson\PycharmProjects\PYTHON\Test.py", line 134, in <module> import tkinter ^^^^^^^^^^^^^^ File "C:\Users\SomePerson\AppData\Local\Programs\Python\Python313\Lib\tkinter\__init__.py", line 38, in <module> import _tkinter # If this fails your Python may not be configured for Tk ^^^^^^^^^^^^^^^ ImportError: DLL load failed while importing _tkinter: The specified procedure could not be found.
3. 回滚旧版本时的异常情况
我怀疑是Python 3.13.5的安装包损坏或者安装不完整,于是尝试重装之前用的3.13.0版本,但重装过程中弹出了错误提示(Error1),卸载3.13.5时也出现了错误(Error2)。另外我想手动查找3.13.5的损坏文件,却完全不知道具体的文件位置。
有没有朋友遇到过类似的情况?或者能给我一些排查和解决的具体建议?
内容来源于stack exchange
相关产品推荐
相关产品推荐

