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

Anaconda Jupyter运行requests_html报websockets无client属性错误

问题原因

AttributeError: module 'websockets' has no attribute 'client' 报错根因如下:

  • requests-html 已多年未维护,仅适配9.x及更低版本的websockets库,高版本websockets重构了内部模块结构,调整了原有的client属性导入路径,因此触发报错
  • 你安装的websocks-client是SOCKS代理相关的第三方包,和报错涉及的websockets库完全无关,无法解决问题
解决步骤
  1. 先卸载无关包和不兼容的高版本websockets
pip uninstall websocks-client websockets -y

如果是Anaconda专属虚拟环境,也可以用conda命令卸载:

conda remove websocks-client websockets -y
  1. 安装requests-html适配的websockets版本
    为了避免安装到其他环境,你可以直接在运行代码的Jupyter Notebook单元格中执行以下命令,给当前Jupyter绑定的环境安装对应版本包:
import sys
!{sys.executable} -m pip install websockets==9.1
  1. 安装完成后重启Jupyter内核,重新运行你的代码即可正常执行。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.03 07:48:03