You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python模块导入报错:AttributeError: 'module'对象无ExecutableDoesntExistsError属性

问题分析与解决

错误翻译

AttributeError: 'module' 对象没有属性 'ExecutableDoesntExistsError'

问题原因

Python标准库自带了一个名为exceptions的模块,当你执行import exceptions时,Python会优先加载系统标准库的这个模块,而非你自己编写的同名文件,因此找不到自定义的ExecutableDoesntExistsError类。

解决办法

方法1:重命名自定义文件(推荐)

把你的exceptions.py改名为非标准库同名的名称,比如custom_exceptions.py,然后修改第二个文件的导入代码:

import custom_exceptions

raise custom_exceptions.ExecutableDoesntExistsError('123')

方法2:调整导入优先级

如果不想重命名文件,可以在导入前将当前目录加入Python搜索路径的最前端,确保优先加载自己的文件:

import sys
sys.path.insert(0, './')  # 将当前目录设为最高优先级
import exceptions

raise exceptions.ExecutableDoesntExistsError('123')

内容的提问来源于stack exchange,提问作者IvanZharov

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 23:49:57