AttributeError: module 'rasa_nlu' has no attribute '__version__' in Rasa 1.8.1

Hi, I am new to Rasa. I tried to use rasa nlu in python. The model can be trained, but when it runs to the last row, it reports an error:


AttributeError Traceback (most recent call last) in ----> 1 model_directory = trainer.persist(‘trained models/’ , fixed_model_name = ‘myfirstbot’)

/opt/anaconda3/lib/python3.7/site-packages/rasa_nlu/model.py in persist(self, path, persistor, project_name, fixed_model_name) 243 metadata[“pipeline”].append(component_meta) 244 → 245 Metadata(metadata, dir_name).persist(dir_name) 246 247 if persistor is not None:

/opt/anaconda3/lib/python3.7/site-packages/rasa_nlu/model.py in persist(self, model_dir) 110 metadata.update({ 111 “trained_at”: datetime.datetime.now().strftime(‘%Y%m%d-%H%M%S’), → 112 “rasa_nlu_version”: rasa_nlu.version, 113 }) 114

AttributeError: module ‘rasa_nlu’ has no attribute ‘version

Here is my code with Python 3.7.4 and Rasa 1.8.1

from rasa_nlu.training_data import load_data
from rasa_nlu.config import RasaNLUModelConfig
from rasa_nlu import config
from rasa_nlu.model import Trainer
from rasa_nlu.model import Metadata, Interpreter
training_data = load_data('data/training_dataset_3_12.json')
trainer = Trainer(config.load("config.yml"))
trainer.train(training_data)
model_directory = trainer.persist('trained models/' ,  fixed_model_name = 'myfirstbot')

@tianpin313 it seems like you’re using the old rasa_nlu package, rather than the rasa package. You’ll need to modify your code to use the rasa package, e.g. from rasa.nlu.model import Trainer