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++编译器
- 找到你的Python安装目录下的
include文件夹(如C:\Python39\include) - 打开Visual Studio Installer,确认已安装「C++桌面开发」组件及对应版本的Windows SDK
- 添加系统环境变量
INCLUDE,值设为Python的include文件夹路径 - 重启命令提示符后,重新执行
pip install chatterbot
- 找到你的Python安装目录下的
手动安装预编译的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
相关产品推荐
相关产品推荐

