ChatterBot安装填坑

安装chatterbot库

我的环境:python3.8
使用pip install chatterbot的命令。
报了一长串的错。

解决办法

链接: https://github.com/gunthercox/ChatterBot 下载开源文件,
解压缩后,进入安装包目录,执行

python setup.py build
python setup.py install

(然后,运行pip list验证是否安装成功

安装spacy库

pip install spacy

写一个chatterbot的小demo

# -*- coding: utf-8 -*-
from chatterbot import ChatBot

# Create a new chat bot named Charlie
chatbot = ChatBot(
    'Tentacles',
    trainer='chatterbot.trainers.ListTrainer'
)

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

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

运行结果报错 :

RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
Traceback (most recent call last):
  File "D:/PycharmProjects/ChatterRobot/chatterdemo.py", line 5, in <module>
    chatbot = ChatBot(
  File "D:\Pytorch\anaconda3\envs\pytorch38\lib\site-packages\chatterbot-1.1.0a7-py3.8.egg\chatterbot\chatterbot.py", line 28, in __init__
  File "D:\Pytorch\anaconda3\envs\pytorch38\lib\site-packages\chatterbot-1.1.0a7-py3.8.egg\chatterbot\utils.py", line 33, in initialize_class
  File "D:\Pytorch\anaconda3\envs\pytorch38\lib\site-packages\chatterbot-1.1.0a7-py3.8.egg\chatterbot\storage\sql_storage.py", line 20, in __init__
  File "D:\Pytorch\anaconda3\envs\pytorch38\lib\site-packages\chatterbot-1.1.0a7-py3.8.egg\chatterbot\storage\storage_adapter.py", line 22, in __init__
  File "D:\Pytorch\anaconda3\envs\pytorch38\lib\site-packages\chatterbot-1.1.0a7-py3.8.egg\chatterbot\tagging.py", line 26, in __init__
  File "D:\Pytorch\anaconda3\envs\pytorch38\lib\site-packages\spacy\__init__.py", line 54, in load
    return util.load_model(
  File "D:\Pytorch\anaconda3\envs\pytorch38\lib\site-packages\spacy\util.py", line 435, in load_model
    raise IOError(Errors.E941.format(name=name, full=OLD_MODEL_SHORTCUTS[name]))  # type: ignore[index]
OSError: [E941] Can't find model 'en'. It looks like you're trying to load a model from a shortcut, which is obsolete as of spaCy v3.0. To load the model, use its full name instead:

nlp = spacy.load("en_core_web_sm")

For more details on the available models, see the models directory: https://spacy.io/models. If you want to create a blank model, use spacy.blank: nlp = spacy.blank("en")

Process finished with exit code 1

问题:Can’t find model ‘en’,To load the model, use its full name instead: nlp = spacy.load(“en_core_web_sm”)

解决办法

下载en的包

python -m spacy download en

下载过程中可能会报错,版本问题之类的,需要你输入全称之类的。
但是最后可以安装成功,安装之后,可以在本地python库目录site-packages中找到这个文件夹,就是装成功了。
在这里插入图片描述

验证

(pytorch38) C:\Users\admin>python
Python 3.8.12 (default, Oct 12 2021, 03:01:40) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import spacy
2022-09-07 12:21:18.620065: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2022-09-07 12:21:18.620203: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
>>> nlp = spacy.load('en_core_web_sm')
>>>

但是demo运行还是报了和spacy相关的错。


–关于pip更新包出现OSError问题

使用 pip install --upgrade 包会报错如下,表示没有权限

ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问。: 'D:\\Pytorch\\anaconda3\\envs\\pytorch38\\Lib\\site-packages\\~umpy\\.libs\\libopenblas.WCDJNK7YVMPZQ2ME2ZZHJJRJ3JIKNDB7.gfortran-win_amd64.dll'
Consider using the `--user` option or check the permissions.

在前面加上python -m, 也就是使用命令

python -m pip install --upgrade 
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值