gpt4 book ai didi

Problem using ChatterBot in Python: AttributeError 'time' has no attribute 'clock'(在Python中使用Chatterbot时出现问题:AttributeError‘time’没有‘Clock’属性)

转载 作者:bug小助手 更新时间:2023-10-27 20:56:35 29 4
gpt4 key购买 nike



I have this code using the chatterbot third-party library:

我有以下使用Chatterbot第三方库的代码:


from chatterbot.trainers import ChatterBotCorpusTrainer
import time
from time import perf_counter

# Import the chatterbot module
import chatterbot

# Create a ChatBot instance with the name
chatbotj = chatterbot.ChatBot('epicurus')

# Create an instance of the ChatterBotCorpusTrainer
trainer = ChatterBotCorpusTrainer(chatbotj)

# Train the chatbot using the Italian corpus
trainer.train('chatterbot.corpus.italian')

exit_conditions = (":q", "quit", "exit")
while True:
query = input("> ")
if query in exit_conditions:
break
else:
response = chatbotj.get_response(query)
print(response)

When I try using the code, I get an error like this from Visual Studio:

当我尝试使用代码时,从Visual Studio收到如下错误:


   Message=module 'time' has no attribute 'clock'
Source=C:\Users\User\source\repos\PythonApplication5\PythonApplication5\PythonApplication5.py
Stack Trace:
File "C:\Users\User\source\repos\PythonApplication5\PythonApplication5\PythonApplication5.py", line 9, in <module> (Current frame)
chatbotj = chatterbot.ChatBot('epicurus')
AttributeError: module 'time' has no attribute 'clock'

I have these packages installed:

我安装了以下程序包:


ChatterBot==1.0.4
chatterbot-corpus==1.2.0
click==8.1.7
colorama==0.4.6
joblib==1.3.2
mathparse==0.1.2
nltk==3.8.1
Pint==0.22
pymongo==3.13.0
python-dateutil==2.7.5
pytz==2023.3.post1
PyYAML==3.13
regex==2023.8.8
six==1.16.0
SQLAlchemy==1.2.19
tqdm==4.66.1
typing_extensions==4.7.1

I tried both with Python 3.9 and 3.11 and with Chatterbot 1.0.5, installing all the individual packages separately after using --install --no-deps (because I had problems using pip install chatterbot --upgrade).

我尝试了使用Python3.9和3.11以及Chatterbot 1.0.5,在使用--install--no-deps之后分别安装了所有单独的包(因为我在使用pip安装Chatterbot--Upgrade时遇到了问题)。


What is wrong, and how do I fix it?

哪里出了问题,我如何修复它?


更多回答

Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.

请澄清您的具体问题或提供额外的细节,以突出您的确切需求。就目前所写的来说,很难确切地说出你在问什么。

This is definitely not a complete stack trace. Please show a complete error message by copying and pasting, starting from the first line you can find that says Traceback (most recent call last):, all the way to the end, and formatting it the same way as the code. If you don't see such a line, use the command line to run the code instead of your IDE.

这绝对不是一个完整的堆栈跟踪。请通过复制和粘贴来显示完整的错误消息,从您可以找到的第一行开始,写着TraceBack(Last Recent Call Last):,一直到最后,并以与代码相同的方式格式化它。如果您没有看到这样的行,请使用命令行而不是您的IDE来运行代码。

优秀答案推荐

You're using an old version of sqlalchemy that relies on the now deprecated time.clock. See requirements.txt. Try updating it

您正在使用的是依赖于现在不推荐使用的time.lock的旧版本的SQLALCHEMY。请参阅Requirements s.txt。试着更新它


pip install sqlalchemy --upgrade

更多回答

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com