安装 使用 chatterbot

安装 chatterbot

pip install chatterbot

如果是python 3.7 安装会成功 使用会出现错误

建议换成python3.6.4

还是执行 pip install chatterbot

如果遇到错误:

PermissionError: [WinError 32] 另一个程序正在使用此文件,进程无法访问。: 'D:\\Users\\zhangsan\\AppData\\Local\\Temp\\pip-build-v66ub_xf\\sqlalchemy\\build\\lib.win-amd64-3.6\\sqlalchemy\\cutils.cp36-win_amd64.pyd'

需要更改编码。
解决方法:
打开你自己的python的包路径,例如:
c:\program files\python36\lib\site-packages\pip\compat_init_.py 约75行

return s.decode('utf_8') 改为return s.decode('cp936')

原因:
编码问题,虽然py3统一用utf-8了。但win下的终端显示用的还是gbk编码。

run的时候
如果提示 缺少 chatterbot_corpus 模块

pip install chatterbot_corpus

测试代码:

rom chatterbot import ChatBot
from chatterbot.trainers import ListTrainer

# Create a new chat bot named Charlie
chatbot = ChatBot('Charlie')

trainer = ListTrainer(chatbot)

trainer.train([
    "Hi, can I help you?",
    "Sure, I'd like to book a flight to Iceland.",
    "Your flight has been booked."
])

# Get a response to the input text 'I would like to book a flight.'
response = chatbot.get_response('I would like to book a flight.')

print(response)
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值