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

Python中pip安装ChatterBot遇preshed编译错误,求解决方案

解决pip install chatterbot时的longintrepr.h缺失错误

解决方案:

  • 切换兼容的Python版本
    longintrepr.h是Python内部头文件,部分旧版preshed(chatterbot的依赖包)对Python3.10+支持不佳。建议切换到Python3.8或3.9版本,再重新执行安装命令。

  • 指定兼容的preshed版本安装
    先单独安装适配性更好的preshed版本,再安装chatterbot:

    pip install preshed==3.0.2
    pip install chatterbot
    
  • 配置Python头文件路径给VC++编译器

    1. 找到你的Python安装目录下的include文件夹(如C:\Python39\include)
    2. 打开Visual Studio Installer,确认已安装「C++桌面开发」组件及对应版本的Windows SDK
    3. 添加系统环境变量INCLUDE,值设为Python的include文件夹路径
    4. 重启命令提示符后,重新执行pip install chatterbot
  • 手动安装预编译的preshed wheel包
    下载与你的Python版本、系统匹配的preshed wheel包(如cp39对应Python3.9,win_amd64对应64位Windows),手动安装后再装chatterbot:

    pip install preshed-3.0.2-cp39-none-win_amd64.whl  # 替换为你下载的文件名
    pip install chatterbot
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.29 02:57:19