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
Related
The error I receive is:
DeprecationWarning: watson-developer-cloud moved to ibm-watson. To get
updates, use the new package.
service = watson_developer_cloud.AssistantV1(
I have tried updating watson-developer-cloud using pip install however I still have the same error.
The code used is below. All done in Python. Just left out the API key from the original code.
Any help is appreciated.
service = watson_developer_cloud.AssistantV1(
iam_apikey= '',
version= '2021-01-20'
import os
from pathlib import Path
import slack
import ibm_watson
import ibm_cloud_sdk_core
import watson_developer_cloud
from ibm_watson import AssistantV1
from dotenv import load_dotenv
)
See here for the instructions on that Python package for IBM Watson services. It is like stated in the warning:
watson-developer-cloud is now named ibm-watson. What you have to do is
pip install ibm-watson
or
pip install --upgrade ibm-watson
Because the packagae is named ibm-watson, you would need to use that name for import...
import ibm-watson
or
from ibm_watson import AssistantV1
See the linked repository for examples.
I am able to pip install (pip install skope-rules) but not import skoperules used for interpretable ML applications (https://github.com/scikit-learn-contrib/skope-rules).
I am getting the following error:
ImportError: cannot import name 'six'
This has been documented as an issue here: https://github.com/scikit-learn-contrib/skope-rules/issues/41
However, the fix suggested (see code snippet below) does not work either:
pip install git+https://github.com/csinva/interpretability-implementations-demos from imodels import SkopeRules
Any ideas on how to import skrules?
This worked for me:
import six
import sys
sys.modules['sklearn.externals.six'] = six
from skrules import SkopeRules
I am attempting to use Nuitka to create a standalone executable from this basic Kivy example hello.py:
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def build(self):
return Button(text='Hello World')
TestApp().run()
When I do python -m nuitka --follow-imports hello.py, Nuitka creates the executable, but when I run this, it fails with
../dist-packages/kivy/event.py", line 8, in import kivy._event No module named _event
The module _event is in fact the c extension module _event.so which Python interpreter finds and loads OK.
My question is - what causes this error? Can I get around this?
It appears that Nuitka can deal with c extension modules generally, e.g. doing python -m nuitka --follow-imports on
from bluetooth import bluez as _btz
print _btz._bt
print "Hello World!"
results in a functioning executable even though module bluez has an import _bluetooth statement referring to a _bluetooth.so extension module:
./hello.bin
<module 'bluetooth._bluetooth' from
'/usr/lib/python2.7/dist-packages/bluetooth/_bluetooth.so'>
Hello World!
In case it is relevant: system is MX Linux 18.3 (Debian Stretch based), Python 2.7.13, Kivy v1.10.1, Nuitka 0.6.8.4
My objective is to speed up Kivy application startup time, as opposed to packaging the application for distribution. For example, I have a RPI2B embedded system running a Kivy app on Buildroot generated Linux. This cold boots in 12 seconds, of which 6 seconds is Kivy app startup time. So for example PyInstaller does not help me here, whilst Nuitka potentially could.
UPDATE
I gave up trying to get this to work with Python 2.7 not sure what happened but I ran into some Nuitka infinite optimisation loop problem. Got a bit further with Python 3.5, these are my notes from when I did it:
sudo apt-get update
sudo apt-get install python3-pip
sudo apt-get install python3-setuptools
sudo apt-get install python3-dev
sudo apt-get install mesa-common-dev
sudo apt install libgl1-mesa-dev
sudo apt-get install chrpath
pip3 install wheel
pip3 install pygame
pip3 install kivy (ended up with 1.11.1)
pip3 install nuitka
followed clues from here
https://github.com/kivy/kivy/wiki/Packaging-Kivy-apps-written-in-Python-3,-targeting-Windows-using-Nuitka
Create dependencies.py:
# external modules
import kivy.cache
import kivy.atlas
import kivy.network
import kivy.network.urlrequest
#import kivy.lib.osc
#import kivy.lib.osc.OSC
#import kivy.lib.osc.oscAPI
import kivy.lib.mtdev
#import kivy.lib.sdl2
import kivy.factory_registers
import kivy.input.recorder
import kivy.input.providers
import kivy.input.providers.tuio
import kivy.input.providers.mouse
#import kivy.input.providers.wm_common
#import kivy.input.providers.wm_touch
#import kivy.input.providers.wm_pen
import kivy.input.providers.hidinput
import kivy.input.providers.linuxwacom
#import kivy.input.providers.mactouch
import kivy.input.providers.mtdev
# compiled modules
import kivy.event
import kivy.graphics.buffer
#import kivy.graphics.c_opengl_debug
import kivy.graphics.compiler
import kivy.graphics.context_instructions
import kivy.graphics.fbo
import kivy.graphics.instructions
import kivy.graphics.opengl
import kivy.graphics.opengl_utils
import kivy.graphics.shader
#import kivy.graphics.stenctil_instructions
import kivy.graphics.texture
import kivy.graphics.transformation
import kivy.graphics.vbo
import kivy.graphics.vertex
import kivy.graphics.vertex_instructions
import kivy.graphics.tesselator
import kivy.graphics.svg
import kivy.properties
import kivy.graphics.cgl_backend
# core
# import kivy.core.audio.audio_gstplayer
# import kivy.core.audio.audio_pygst
import kivy.core.audio.audio_sdl2
# import kivy.core.audio.audio_pygame
# import kivy.core.camera.camera_avfoundation
# import kivy.core.camera.camera_pygst
# import kivy.core.camera.camera_opencv
# import kivy.core.camera.camera_videocapture
import kivy.core.clipboard.clipboard_sdl2
# import kivy.core.clipboard.clipboard_android
# import kivy.core.clipboard.clipboard_pygame
# import kivy.core.clipboard.clipboard_dummy
# import kivy.core.image.img_imageio
# import kivy.core.image.img_tex
# import kivy.core.image.img_dds
import kivy.core.image.img_sdl2
# import kivy.core.image.img_pygame
# import kivy.core.image.img_pil
# import kivy.core.image.img_gif
# import kivy.core.spelling.spelling_enchant
# import kivy.core.spelling.spelling_osxappkit
import kivy.core.text.text_sdl2
# import kivy.core.text.text_pygame
# import kivy.core.text.text_sdlttf
# import kivy.core.text.text_pil
# import kivy.core.video.video_gstplayer
# import kivy.core.video.video_pygst
# import kivy.core.video.video_ffmpeg
# import kivy.core.video.video_pyglet
# import kivy.core.video.video_null
import kivy.core.window.window_info
import kivy.graphics.cgl_backend.cgl_glew
import kivy.graphics.cgl_backend.cgl_gl
import kivy.graphics.cgl_backend.cgl_sdl2
import kivy.core.window.window_sdl2
#import kivy.core.window.window_egl_rpi
# import kivy.core.window.window_pygame
# import kivy.core.window.window_sdl
# import kivy.core.window.window_x11
Use it like this:
python3 -m nuitka --include-plugin-files=dependencies.py --standalone hello.py
cp -r <path/to>/lib/python3.5/site-packages/kivy/data <path/to>/hello.dist/kivy/
./hello.dist/hello
Any "ImportError: No module named <...>" is remedied by adding a corresponding import statement in dependencies.py
However resulting executable appears to be no faster than original python script. And it wouldn't run under a separate MX Linux instance on the same machine, I got this:
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 155 (GLX)
Minor opcode of failed request: 3 (X_GLXCreateContext)
Value in failed request: 0x0
Serial number of failed request: 72
Current serial number in output stream: 73
I'm a relatively inexperienced programmer and I ran these import statements last week on my computer without a problem but now this week when I run the following statements in particular the wkhtmltopdf import I run into an error.
import pyodbc
import pymysql
import numpy as np
import pandas as pd
import datetime
import jinja2
import wkhtmltopdf
from wkhtmltopdf.main import WKhtmlToPdf
import datetime
import calendar
from pathlib import Path
This leads to this error
enter image description here
Any help is appreciated
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.