簡體   English   中英

無法在 Anaconda 中安裝 chatterbot

[英]Can not install chatterbot in Anaconda

使用 Python 3.7 在 Anaconda 中安裝chatterbot時,出現以下錯誤:

找到現有安裝:PyYAML 3.13 無法卸載“PyYAML”。 這是一個 distutils 安裝的項目,因此我們無法准確確定哪些文件屬於它,這只會導致部分卸載。

使用 Python 3.7 在conda環境中安裝chatterbot

  • 使用 Python 3.7 創建新的conda環境
conda create --name chatterbot_example python=3.7
  • 激活環境:
source activate chatterbot_example
  • 在環境中安裝chatterbotchatterbot-corpus
pip install chatterbot
pip install chatterbot-corpus
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

chatbot = ChatBot('Ron Obvious')

# Create a new trainer for the chatbot
trainer = ChatterBotCorpusTrainer(chatbot)

# Train the chatbot based on the english corpus
trainer.train("chatterbot.corpus.english")

# Get a response to an input statement
print(chatbot.get_response("Hello, how are you today?"))
  • 運行程序:
python example.py

輸出:

python example.py
[nltk_data] Downloading package stopwords to /home/cefalo/nltk_data...
[nltk_data]   Package stopwords is already up-to-date!
[nltk_data] Downloading package averaged_perceptron_tagger to
[nltk_data]     /home/cefalo/nltk_data...
[nltk_data]   Package averaged_perceptron_tagger is already up-to-
[nltk_data]       date!
Training ai.yml: [####################] 100%
Training botprofile.yml: [####################] 100%
Training computers.yml: [####################] 100%
Training conversations.yml: [####################] 100%
Training emotion.yml: [####################] 100%
Training food.yml: [####################] 100%
Training gossip.yml: [####################] 100%
Training greetings.yml: [####################] 100%
Training health.yml: [####################] 100%
Training history.yml: [####################] 100%
Training humor.yml: [####################] 100%
Training literature.yml: [####################] 100%
Training money.yml: [####################] 100%
Training movies.yml: [####################] 100%
Training politics.yml: [####################] 100%
Training psychology.yml: [####################] 100%
Training science.yml: [####################] 100%
Training sports.yml: [####################] 100%
Training trivia.yml: [####################] 100%
Tell me a joke

系統信息:

  • 操作系統:Ubuntu 16.04 LTS
  • 處理器:英特爾® 酷睿™ i7-4600M

康達版本信息:

conda --version
conda 4.5.11

安裝的軟件包:

attrs==19.1.0
blis==0.2.4
certifi==2019.3.9
chardet==3.0.4
ChatterBot==1.0.5
chatterbot-corpus==1.2.0
cymem==2.0.2
idna==2.8
jsonschema==3.0.1
mathparse==0.1.2
murmurhash==1.0.2
nltk==3.4.1
numpy==1.16.3
Pint==0.9
plac==0.9.6
preshed==2.0.1
pymongo==3.8.0
pyrsistent==0.15.2
python-dateutil==2.7.5
pytz==2019.1
PyYAML==3.13
requests==2.22.0
six==1.12.0
spacy==2.1.4
SQLAlchemy==1.2.19
srsly==0.0.5
thinc==7.0.4
tqdm==4.32.1
urllib3==1.25.2
wasabi==0.2.2

更新@arsho 共享的解決方案。

對於 4.6 之前的 conda 版本,請使用:

  • Windows: activate snakes
  • macOS 和 Linux: source activate snakes

對於 conda 4.6 及更高版本,請使用:

  • Windows、macOS、Linux: conda activate snakes

康達 YAML

更簡單的安裝是使用 YAML,由於所有 Conda 包構建都是預編譯的,因此速度也會明顯加快:

聊天機器人.yaml

name: chatterbot
channels:
  - conda-forge
dependencies:
  ## python core
  - python=3.7
  - pip

  ## dependencies
  - python-dateutil=2.8
  - pytz
  - pyyaml >=3.12,<4.0
  - six >=1.5
  - spacy=2.1
  - sqlalchemy=1.3

  ## pip installs
  - pip:
    - chatterbot
    - chatterbot-corpus

安裝

conda env create -n chatterbot -f chatterbot.yaml

請注意,要在@arsho 的回答中運行示例,我首先需要

conda activate chatterbot

## install English (only needed once)
python -m spacy download en

然后python example.py工作方式類似。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM