模块未找到错误:没有名为'gevent.wsgi'的模块。

16

在运行一个flask应用程序时,我遇到了以下错误:

from gevent.wsgi import WSGIServer
ModuleNotFoundError: No module named 'gevent.wsgi'

gevent已经安装,并且满足要求。

Pip版本为10.11,Python版本为3.6。
操作系统:Windows 10 x64
使用Anaconda虚拟机

这段代码在另一台机器上可以运行,所以我在某个地方缺少配置,但我找不到它的踪迹/位置。

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import logging
import json
from pprint import pprint
from rasa_core.channels import HttpInputChannel
from rasa_core import utils
from rasa_core.agent import Agent
from rasa_core.interpreter import RasaNLUInterpreter
from rasa_core.channels.channel import UserMessage
from rasa_core.channels.direct import CollectingOutputChannel
from rasa_core.channels.rest import HttpInputComponent
from flask import Blueprint, request, jsonify, abort    
def run(serve_forever=True):
#path to your NLU model
interpreter = RasaNLUInterpreter("models/nlu/default/current")
# path to your dialogues models
agent = Agent.load("models/dialogue", interpreter=interpreter)
#http api endpoint for responses
input_channel = SimpleWebBot()
if serve_forever:
    agent.handle_channel(HttpInputChannel(5004, "/chat", input_channel))
return agent
if __name__ == '__main__':
   utils.configure_colored_logging(loglevel="INFO")
   run()
2个回答

24

尝试使用:

from gevent.pywsgi import WSGIServer

改为:

from gevent.wsgi import WSGIServer

上面的观点是正确的,但这是rasa-core库的问题。升级到0.9版本后,问题得到了解决。 - Praveen R

5
您引用的导入语句需要更新为:
from gevent.pywsgi import WSGIServer

gevent.wsgi模块已被弃用,并在发布gevent 1.3时移除。它的替代品是gevent.pywsgi模块,该模块已经存在一段时间了。 看起来在您的情况下,您正在使用带有错误导入行的rasa-core库。这在0.9.0版本中已修复,因此您应该将该依赖项更新到较新的版本。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接