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

Windows启动Python 3遇AttributeError:collections无Callable属性

问题解决:Python 3.10启动时sys.__interactivehook__调用失败

错误原因

Python 3.3及以上版本中,collections.Callable已被迁移到collections.abc.Callable,而你安装的pyreadline版本过旧,仍在使用废弃的API,导致启动交互式环境时触发AttributeError。

解决方案

方法1:升级到兼容的readline替代包

在终端执行以下命令,安装适配Python3的pyreadline3:

pip install --upgrade pyreadline3

(原pyreadline已停止维护,pyreadline3是其适配Python3的分支)

方法2:临时禁用用户站点包启动Python

如果需要快速启动Python环境,可使用以下命令跳过有问题的readline模块加载:

python -s

参数-s会禁用用户站点包的导入,避免触发报错的钩子函数。

方法3:手动修改兼容文件(不推荐)

找到报错文件C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\pyreadline\py3k_compat.py,将第8行的:

return isinstance(x, collections.Callable)

修改为:

return isinstance(x, collections.abc.Callable)

注意:该修改会在包更新后被覆盖,仅作为临时应急方案。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.16 12:21:49