Apress / building-chatbots-with-python

Source Code for 'Building Chatbots with Python' by Sumit Raj
Other
101 stars 75 forks source link

Chapter 4 training the Model is throwing an error #9

Open Rahul-Choudhary-3614 opened 3 years ago

Rahul-Choudhary-3614 commented 3 years ago

TypeError Traceback (most recent call last)

in ----> 1 train_horoscopebot('./data/data.json', 'config.json', './models/nlu') in train_horoscopebot(data_json, config_file, model_dir) 1 def train_horoscopebot(data_json, config_file, model_dir): 2 training_data = load_data(data_json) ----> 3 trainer = Trainer(config.load(config_file)) 4 trainer.train(training_data) 5 model_directory = trainer.persist(model_dir, fixed_model_name = 'horoscopebot') /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/rasa_nlu/model.py in __init__(self, cfg, component_builder, skip_validation) 150 # required packages are available 151 if not self.skip_validation: --> 152 components.validate_requirements(cfg.component_names) 153 154 # build pipeline /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/rasa_nlu/components.py in validate_requirements(component_names) 53 for component_name in component_names: 54 component_class = registry.get_component_class(component_name) ---> 55 failed_imports.update(find_unavailable_packages( 56 component_class.required_packages())) 57 if failed_imports: # pragma: no cover /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/rasa_nlu/components.py in find_unavailable_packages(package_names) 37 for package in package_names: 38 try: ---> 39 importlib.import_module(package) 40 except ImportError: 41 failed_imports.add(package) /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py in import_module(name, package) 125 break 126 level += 1 --> 127 return _bootstrap._gcd_import(name[level:], package, level) 128 129 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/_bootstrap.py in _gcd_import(name, package, level) /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/_bootstrap.py in _find_and_load(name, import_) /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_) /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/_bootstrap.py in _load_unlocked(spec) /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/_bootstrap_external.py in exec_module(self, module) /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds) /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sklearn/__init__.py in 62 else: 63 from . import __check_build ---> 64 from .base import clone 65 from .utils._show_versions import show_versions 66 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sklearn/base.py in 12 from scipy import sparse 13 from .externals import six ---> 14 from .utils.fixes import signature 15 from .utils import _IS_32BIT 16 from . import __version__ /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sklearn/utils/__init__.py in 12 from .murmurhash import murmurhash3_32 13 from .class_weight import compute_class_weight, compute_sample_weight ---> 14 from . import _joblib 15 from ..exceptions import DataConversionWarning 16 from .fixes import _Sequence as Sequence /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sklearn/utils/_joblib.py in 20 from joblib import parallel_backend, register_parallel_backend 21 else: ---> 22 from ..externals import joblib 23 from ..externals.joblib import logger 24 from ..externals.joblib import dump, load /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sklearn/externals/joblib/__init__.py in 117 from .numpy_pickle import load 118 from .compressor import register_compressor --> 119 from .parallel import Parallel 120 from .parallel import delayed 121 from .parallel import cpu_count /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sklearn/externals/joblib/parallel.py in 26 from .my_exceptions import TransportableException 27 from .disk import memstr_to_bytes ---> 28 from ._parallel_backends import (FallbackToBackend, MultiprocessingBackend, 29 ThreadingBackend, SequentialBackend, 30 LokyBackend) /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sklearn/externals/joblib/_parallel_backends.py in 20 from .pool import MemmappingPool 21 from multiprocessing.pool import ThreadPool ---> 22 from .executor import get_memmapping_executor 23 24 # Compat between concurrent.futures and multiprocessing TimeoutError /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sklearn/externals/joblib/executor.py in 12 from .disk import delete_folder 13 from ._memmapping_reducer import get_memmapping_reducers ---> 14 from .externals.loky.reusable_executor import get_reusable_executor 15 16 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sklearn/externals/joblib/externals/loky/__init__.py in 10 11 from .backend.context import cpu_count ---> 12 from .backend.reduction import set_loky_pickler 13 from .reusable_executor import get_reusable_executor 14 from .cloudpickle_wrapper import wrap_non_picklable_objects /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sklearn/externals/joblib/externals/loky/backend/reduction.py in 123 # global variable to change the pickler behavior 124 try: --> 125 from sklearn.externals.joblib.externals import cloudpickle # noqa: F401 126 DEFAULT_ENV = "cloudpickle" 127 except ImportError: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/__init__.py in 1 from __future__ import absolute_import 2 ----> 3 from .cloudpickle import * 4 5 __version__ = '0.8.0' /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py in 150 151 --> 152 _cell_set_template_code = _make_cell_set_template_code() 153 154 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py in _make_cell_set_template_code() 131 ) 132 else: --> 133 return types.CodeType( 134 co.co_argcount, 135 co.co_kwonlyargcount, TypeError: an integer is required (got type bytes
jinwenhua commented 2 years ago

I got an error too:


TypeError Traceback (most recent call last) /Users/kinbunhua/cds522/chatbot/horoscope_bot/building-chatbots-with-python-master/Chapter IV/horoscope_bot/rasa-nlu.ipynb Cell 2 in <cell line: 1>() ----> 1 train_horoscopebot('./data/data.json', 'config.json', './models/nlu')

/Users/kinbunhua/cds522/chatbot/horoscope_bot/building-chatbots-with-python-master/Chapter IV/horoscope_bot/rasa-nlu.ipynb Cell 2 in train_horoscopebot(data_json, config_file, model_dir) 7 def train_horoscopebot(data_json, config_file, model_dir): 8 training_data = load_data(data_json) ----> 9 trainer = Trainer(config.load(config_file)) 10 trainer.train(training_data) 11 model_directory = trainer.persist(model_dir, fixed_model_name = 'horoscopebot')

File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/rasa_nlu/config.py:44, in load(filename, **kwargs) 42 if filename is not None: 43 try: ---> 44 file_config = utils.read_yaml_file(filename) 45 except yaml.parser.ParserError as e: 46 raise InvalidConfigError("Failed to read configuration file " 47 "'{}'. Error: {}".format(filename, e))

File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/rasa_nlu/utils/init.py:236, in read_yaml_file(filename) 234 def read_yaml_file(filename): 235 fix_yaml_loader() --> 236 return yaml.load(read_file(filename, "utf-8"))

TypeError: load() missing 1 required positional argument: 'Loader'

sumit12dec commented 2 years ago

Did you install all the libraries with the exact version specific in the book? Can you ensure it matches exactly the same version as it is backward incompatible.

jinwenhua commented 2 years ago

the version of rasa-nlu is 0.13.2