ModuleNotFoundError: No module named 'gevent.wsgi' - python

I'm getting the following error while running a flask app:
from gevent.wsgi import WSGIServer
ModuleNotFoundError: No module named 'gevent.wsgi'
gevent is already installed and the requirement is satisfied.
Pip version is 10.11 and Python 3.6.
OS: Windows 10 x64
Using Anaconda VM
This same code worked in another machine, so somewhere I am missing configuration, but I can't track/find it.
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()

Try using:
from gevent.pywsgi import WSGIServer
Instead of:
from gevent.wsgi import WSGIServer

The import statement you quoted needs to be updated to:
from gevent.pywsgi import WSGIServer
The gevent.wsgi module has been deprecated and was removed when gevent 1.3 was released. Its replacement is the gevent.pywsgi module, which has been around for some time.
It looks like in your case, the rasa-core library you're using is the one with the bad import line. This was fixed starting in the 0.9.0 release, so you should update that dependency to a newer version.

Related

Import error even though file is clearly in path

I am running a script and I am getting the error:
Traceback (most recent call last):
File "common/tensorflow/run_tf_benchmark.py", line 30, in <module>
from common.base_benchmark_util import BaseBenchmarkUtil
ModuleNotFoundError: No module named 'common'
I am running on an ec2 instance with the following AMI: Deep Learning AMI (Ubuntu 16.04) Version 25.0 (ami-025c308193ac1a136) and I am also working in the tensorflow_p36 anaconda environment that comes from the AMI. My Ubuntu directory is structured as so:
home
--ubuntu
--benchmark_models
--benchmark
--common
--__init__.py
--base_benchmark_util.py
--tensorflow
--run_tf_benchmark.py
--__init__.py
Note, there are other files in the directory, but these are the relevant python files.
Currently, the imports at the top of run_tf_benchmark.py are
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import sys
sys.path.append('/home/ubuntu/benchmark_models/benchmarks/common')
print(sys.path)
from argparse import ArgumentParser
from common.base_benchmark_util import BaseBenchmarkUtil
and the printed sys.path is
['/home/ubuntu/benchmark_models/benchmarks/common/tensorflow', '/home/ubuntu/src/cntk/bindings/python',
'/home/ubuntu/benchmark_models/models/image_recognition/tensorflow/mobilenet_v2', '/home/ubuntu/models',
'/home/ubuntu/models/research', '/home/ubuntu/models/research/slim',
'/home/ubuntu/anaconda3/lib/python36.zip', '/home/ubuntu/anaconda3/lib/python3.6',
'/home/ubuntu/anaconda3/lib/python3.6/lib-dynload', '/home/ubuntu/anaconda3/lib/python3.6/site-packages',
'/home/ubuntu/benchmark_models/benchmarks/common']
I can clearly see common in the python path, but the import error still happens. What am I doing wrong?
Just remove 'common' while importing because you are already in 'common' directory
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import sys
sys.path.append('/home/ubuntu/benchmark_models/benchmarks/common')
print(sys.path)
from argparse import ArgumentParser
from base_benchmark_util import BaseBenchmarkUtil
Alright, I solved the issue. The issue was that I added /home/ubuntu/benchmark_models/benchmarks/common, not /home/ubuntu/benchmark_models/benchmarks/. By import benchmarks, it also allowed all of my other code to import common as well.

Import Error: Rasa Core

I am trying to run the chatbot on windows 10. Python version I am using is Python 3.6.6. I installed rasa-core using pip3 install rasa_core and the installation was completed.
But every time I run my code, I get ImportError: No module named rasa_core.policies.keras_policy.
here are the import libraries:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import argparse
import logging
import warnings
import csv
import pandas as pd
import unicodedata
from rasa_core.policies.keras_policy import KerasPolicy
from rasa_core import utils
from rasa_core.actions import Action
from rasa_core.actions.forms import FormAction
from rasa_core.agent import Agent
from rasa_core.channels.console import ConsoleInputChannel
from rasa_core.events import SlotSet
from rasa_core.events import AllSlotsReset
from rasa_core.featurizers import (
MaxHistoryTrackerFeaturizer,
BinarySingleStateFeaturizer)
from rasa_core.interpreter import RasaNLUInterpreter
from rasa_core.policies.memoization import MemoizationPolicy
from rasa_nlu.model import Metadata, Interpreter
How can I get rid of Import Errors related to rasa-core?
What version of rasa-core are you using?
For e.g. on my mac Below are versions.
pip freeze |grep -i rasa
rasa-core==0.8.2
rasa-core-sdk==0.11.4
rasa-nlu==0.11.4
for rasa-core==0.8.2 class KerasPolicy is in
python3.6/site-packages/rasa_core/policies/keras_policy.py.
Hence you would import it using,
from rasa_core.policies.keras_policy import KerasPolicy
However, if you are using latest version rasa-core. for e.g.
pip freeze |grep -i rasa
rasa-core==0.12.0a3
rasa-core-sdk==0.11.4
rasa-nlu==0.13.3
Then class KerasPolicy is in
/python3.6/site-packages/rasa_core/policies/keras_policy.py .
Hence you would import it using
from rasa_core.policies.keras_policy import KerasPolicy
It appears that you are using an older version of rasa-core and trying newer versions based example.
You need to upgrade both rasa-core and rasa-nlu.
Here's link to latest requirement.txt that you can download.
After that simply run following to get dependencies installed along-with rasa-core and rasa-nlu.
pip install -r requirement.txt

AWS Lambda with Zappa fails on "Unable to import module 'handler': No module named builtins"

I've deployed my application to AWS Lambda with Zappa. The deployment went fine without any issues. But when I try to reach the app via AWS API Gateway I get a 500 response.
The logs says
Unable to import module 'handler': No module named builtins
The environment runs on Python 2.7. I've added future to the Pipfile but it still won't work.
When I check the code in Lambda I can see the following code
from __future__ import unicode_literals
import base64
import boto3
import collections
import datetime
import importlib
import inspect
import json
import logging
import os
import sys
import traceback
import zipfile
from builtins import str
I can't find what can be wrong. Does anyone have a clue?
I solved the problem. I'm using pipenv to install my packages, but for some reason the packages wasn't installed inside the virtual environment, which made Zappa to not include them to AWS Lambda. I had to install them manually in PyCharm by going through Settings > Project > Project Interpreter and add the packages there. Thanks for your help.

request_kerberos doesn't work

Are you able to tell me why I cannot use the request_kerberos module ? this is my code:
from django.http import HttpResponseNotFound ,HttpResponseRedirect
import requests
from requests_kerberos import HTTPKerberosAuth, OPTIONAL
I have already installed this module ,but when I'm opening the webpage I see that:
No module named winkerberos
I've checked the code and the problem is here ,kerberos.py file, first 4 lines:
try:
import kerberos
except ImportError:
import winkerberos as kerberos
winkerberos is for Windows OS and I'm using the CentOS
So, why my system cannot import that module ?

tornado.database Importerror: No module named database

I'm using a fork of Bret Taylor's 'socialcookbook' (https://github.com/finiteloop/socialcookbook) which uses "import tornado.database" - and it's worked perfectly until yesterday (the 3.01 build?) and now I'm getting an ImportError: no module named database when I compile on Heroku (using Python).
My requirements.txt file is simple:
mysql-python
tornado
My import statements:
import base64
import datetime
import functools
import json
import hashlib
import hmac
import time
import logging
import os
import smtplib #for mandrill email notifications
import httplib #for custom error handler
import re
import string
import tornado.database
import tornado.escape
import tornado.httpclient
import tornado.ioloop
import tornado.web
import urllib
import urllib2
import urlparse
from tornado.options import define, options
import facebook
Any thoughts? I'm having a hard time troubleshooting this one and I can't push new builds (old builds work fine if I rollback on Heroku, though, oddly..)
As it turns out, Tornado 3.0 has deprecated tornado.database and replace it with torndb: https://github.com/bdarnell/torndb
So the fix is to simply replace all tornado.database references with torndb and add torndb to the requirements.txt file.

Categories

Resources