ImportError:没有名为aiml的模块

时间:2019-04-21 02:00:00

标签: python-2.7 artificial-intelligence aiml

当我尝试运行python服务器:python main.py时,出现此错误: 我正在使用php 2.7.x和aiml版本0.8.6。谁能告诉我问题出在哪里。我以前一直在使用此代码,这是该错误第一次出现

Traceback (most recent call last):
 File "main.py", line 2, in <module>
 import aiml
ImportError: No module named aiml

这是我的main.py代码:

from flask import Flask, render_template, request, jsonify
import aiml
import os

 app = Flask(__name__)

 @app.route("/")
  def hello():
    return render_template('chat.html')

  @app.route("/ask", methods=['POST'])
        def ask():
    message = request.form['messageText'].encode('utf-8').strip()

    kernel = aiml.Kernel()

    if os.path.isfile("bot_brain.brn"):
        kernel.bootstrap(brainFile = "bot_brain.brn")
    else:
        kernel.bootstrap(learnFiles = os.path.abspath("aiml/std-startup.xml"), commands = "load aiml b")
        kernel.saveBrain("bot_brain.brn")

    # kernel now ready for use
    while True:
        if message == "quit":
            exit()
        elif message == "save":
            kernel.saveBrain("bot_brain.brn")
        else:
            bot_response = kernel.respond(message)
            # print bot_response
            return jsonify({'status':'OK','answer':bot_response})

if __name__ == "__main__":
    app.run(host='0.0.0.0', debug=True)

0 个答案:

没有答案