感谢您花时间帮助我解决问题。我最近偶然发现了 ChatterBot,这是一个 Python 库,可以创建能够进行自然语言对话的聊天机器人。话虽如此,我对编程仍然比较陌生,并且正在努力运行示例代码。我正在使用 Python 3.7,并在 Visual Studio Code 中进行编码。
要求已安装,
pip install -r Chatterbot-masters/requirements.txt
:
mathparse>=0.1,<0.2
python-dateutil>=2.8,<2.9
sqlalchemy>=1.3,<1.4
pytz
然后我复制了下面的示例代码。
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
# Create a new instance of a ChatBot
bot = ChatBot(
'Example Bot',
storage_adapter='chatterbot.storage.SQLStorageAdapter',
logic_adapters=[
{
'import_path': 'chatterbot.logic.BestMatch',
'default_response': 'I am sorry, but I do not understand.',
'maximum_similarity_threshold': 0.90
}
]
)
trainer = ListTrainer(bot)
# Train the chat bot with a few responses
trainer.train([
'How can I help you?',
'I want to create a chat bot',
'Have you read the documentation?',
'No, I have not',
'This should help get you started: http://chatterbot.rtfd.org/en/latest/quickstart.html'
])
# Get a response for some unexpected input
response = bot.get_response('How do I make an omelette?')
print(response)
PS C:\Users\Joe\Desktop\Kindra> python example.py
Traceback (most recent call last):
File "example.py", line 13, in <module>
'maximum_similarity_threshold': 0.90
File "C:\Users\Joe\AppData\Local\Programs\Python\Python37\lib\site-packages\chatterbot\chatterbot.py", line 28, in __init__
self.storage = utils.initialize_class(storage_adapter, **kwargs)
File "C:\Users\Joe\AppData\Local\Programs\Python\Python37\lib\site-packages\chatterbot\utils.py", line 33, in initialize_class
return Class(*args, **kwargs)
File "C:\Users\Joe\AppData\Local\Programs\Python\Python37\lib\site-packages\chatterbot\storage\sql_storage.py", line 20, in __init__
super().__init__(**kwargs)
File "C:\Users\Joe\AppData\Local\Programs\Python\Python37\lib\site-packages\chatterbot\storage\storage_adapter.py", line 23, in __init__
'tagger_language', languages.ENG
File "C:\Users\Joe\AppData\Local\Programs\Python\Python37\lib\site-packages\chatterbot\tagging.py", line 20, in __init__
import spacy
File "C:\Users\Joe\AppData\Local\Programs\Python\Python37\lib\site-packages\spacy\__init__.py", line 12, in <module>
from .cli.info import info as cli_info
File "C:\Users\Joe\AppData\Local\Programs\Python\Python37\lib\site-packages\spacy\cli\__init__.py", line 1, in <module>
from .download import download # noqa: F401
File "C:\Users\Joe\AppData\Local\Programs\Python\Python37\lib\site-packages\spacy\cli\download.py", line 5, in <module>
import requests
File "C:\Users\Joe\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\__init__.py", line 43, in <module>
import urllib3
File "C:\Users\Joe\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\__init__.py", line 39, in <module>
"urllib3 v2.0 only supports OpenSSL 1.1.1+, currently "
ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with OpenSSL 1.1.0h 27 Mar 2018. See: https://github.com/urllib3/urllib3/issues/2168
python -m OpenSSL.debug
>>
pyOpenSSL: 23.1.1
cryptography: 40.0.2
cffi: 1.15.1
cryptography's compiled against OpenSSL: OpenSSL 3.1.0 14 Mar 2023
cryptography's linked OpenSSL: OpenSSL 3.1.0 14 Mar 2023
Python's OpenSSL: OpenSSL 1.1.0h 27 Mar 2018
Python executable: C:\Users\Joe\AppData\Local\Programs\Python\Python37\python.exe
Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]
Platform: win32
sys.path: ['C:\\Users\\Joe\\Desktop\\Kindra', 'C:\\Users\\Joe\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip', 'C:\\Users\\Joe\\AppData\\Local\\Programs\\Python\\Python37\\DLLs', 'C:\\Users\\Joe\\AppData\\Local\\Programs\\Python\\Python37\\lib', 'C:\\Users\\Joe\\AppData\\Local\\Programs\\Python\\Python37', 'C:\\Users\\Joe\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']
python -c "import ssl; print(ssl.OPENSSL_VERSION)"
时:
OpenSSL 1.1.0h 27 Mar 2018
我已经从 https://slproweb.com/products/Win32OpenSSL.html下载了“Win64 OpenSSL v1.1.1t”。
我按照安装程序的提示进行操作,没有进行任何更改。
然后我提取“bin”文件夹并将其粘贴到“C:\Users\Joe\AppData\Local\Programs\Python\Python37\Lib\site-packages\OpenSSL”
我将“C:\Users\Joe\AppData\Local\Programs\Python\Python37\Lib\site-packages\OpenSSL in”添加到我的环境变量
当我返回代码并运行“python example.py”时,我收到上面概述的重复错误。
TLDR:ChatterBot 示例代码返回有关 OpenSSL 的错误。无法更新它来挽救我的生命。错误:“urllib3 v2.0 仅支持 OpenSSL 1.1.1+,当前 'ssl' 模块是使用 OpenSSL 1.1.0h 编译的” 使用 Python 3.7
pip install urllib3==1.26.6
为我解决了这个问题