我正在使用condapython3.6.9开发我的AI聊天机器人项目。我得到以下错误。如何修复以下错误?

2024-03-29 13:00:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用python制作一个AI聊天机器人。你知道吗

我已经安装了所有必需的pip包:

import nltk
from nltk.stem.lancaster import LancasterStemmer
stemmer = LancasterStemmer()

import numpy 
import tflearn
import tensorflow
import random
import json


with open("intents.json") as file:
    data = json.load(file)

print(data)

期望值:

(VCB) C:\Users\Aravind Nallajerla\Desktop\Capstone Project\VCB>python main.py

{
    'intents': [{
        'tag': 'greeting',
        'patterns': ['Hi', 'How are you', 'Is anyone there?', 'Hello', 'Good day', 'Whats up'],
        'responses': ['Hello!', 'Good to see you again!', 'Hi there, how can I help?'],
        'context_set': ''
    }, {
        'tag': 'goodbye',
        'patterns': ['cya', 'See you later', 'Goodbye', 'I am Leaving', 'Have a Good day'],
        'responses': ['Sad to see you go :(', 'Talk to you later', 'Goodbye!'],
        'context_set': ''
    }, {
        'tag': 'age',
        'patterns': ['how old', 'how old is tim', 'what is your age', 'how old are you', 'age?'],
        'responses': ['I am 18 years old!', '18 years young!'],
        'context_set': ''
    }, {
        'tag': 'name',
        'patterns': ['what is your name', 'what should I call you', 'whats your name?'],
        'responses': ['You can call me Tim.', "I'm Tim!", "I'm Tim aka Tech With Tim."],
        'context_set': ''
    }, {
        'tag': 'shop',
        'patterns': ['Id like to buy something', 'whats on the menu', 'what do you reccommend?', 'could i get something to eat'],
        'responses': ['We sell chocolate chip cookies for $2!', 'Cookies are on the menu!'],
        'context_set': ''
    }, {
        'tag': 'hours',
        'patterns': ['when are you guys open', 'what are your hours', 'hours of operation'],
        'responses': ['We are open 7am-4pm Monday-Friday!'],
        'context_set': ''
    }]
} 

实际值:

Traceback (most recent call last): File "main.py", line 6, in import tflearn File "C:\Users\Aravind Nallajerla\AppData\Local\conda\conda\envs\VCB\lib\site-packages\tflearn__init__.py", line 4, in from . import config File "C:\Users\Aravind Nallajerla\AppData\Local\conda\conda\envs\VCB\lib\site-packages\tflearn\config.py", line 5, in from .variables import variable File "C:\Users\Aravind Nallajerla\AppData\Local\conda\conda\envs\VCB\lib\site-packages\tflearn\variables.py", line 7, in from tensorflow.contrib.framework.python.ops import add_arg_scope as contrib_add_arg_scope ModuleNotFoundError: No module named 'tensorflow.contrib


Tags: tofrompyimportyoutagcontextresponses