# Rasa 1.4.6 - Python code to Train - Test manually

**URL:** <https://forum.rasa.com/t/rasa-1-4-6-python-code-to-train-test-manually/21707>\
**Category:** Rasa Open Source\
**Created:** [November 26, 2019, 6:09am UTC](https://forum.rasa.com/t/rasa-1-4-6-python-code-to-train-test-manually/21707 "2019-11-26T06:09:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kktowin](https://avatars.discourse-cdn.com/v4/letter/k/a183cd/32.png) [@kktowin](https://forum.rasa.com/u/kktowin)\
**Post date:** [November 26, 2019, 6:09am UTC](https://forum.rasa.com/t/rasa-1-4-6-python-code-to-train-test-manually/21707/1 "2019-11-26T06:09:11Z")

</div>

Python version : 3.6 OS - MacOS Rasa installed in virtual environment

Used the below code to train the model from rasa.train import train\_nlu import os

```
module_directory = os.path.join("/Users/kishorekumarg/Desktop/models")
module_name = "20191124-210721.tar.gz"
config_file = '/Users/kishorekumarg/Downloads/Rasa/nlu_model_config.json'
nlu_data = '/Users/kishorekumarg/Downloads/rasa_training_en.json'

train_nlu(
    config=config_file,
    nlu_data=nlu_data,
    output=module_directory,
    fixed_model_name=module_name
)
print('done')

```

Inside the Virtual environment executed the above code and got the model trained as below. (venv) kishorekumarg@KISHOREs-MacBook-Pro programs % python traincopy.py

```
Training NLU model...

WARNING:tensorflow:From /Users/kishorekumarg/Desktop/venv/lib/python3.6/site-packages/tensor2tensor/utils/expert_utils.py:68: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.

WARNING:tensorflow:

The TensorFlow contrib module will not be included in TensorFlow 2.0.

For more information, please see:

* https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md

* https://github.com/tensorflow/addons

* https://github.com/tensorflow/io (for I/O related ops)

If you depend on functionality not listed there, please file an issue.

WARNING:tensorflow:From /Users/kishorekumarg/Desktop/venv/lib/python3.6/site-packages/tensor2tensor/utils/adafactor.py:27: The name tf.train.Optimizer is deprecated. Please use tf.compat.v1.train.Optimizer instead.

WARNING:tensorflow:From /Users/kishorekumarg/Desktop/venv/lib/python3.6/site-packages/tensor2tensor/utils/multistep_optimizer.py:32: The name tf.train.AdamOptimizer is deprecated. Please use tf.compat.v1.train.AdamOptimizer instead.

WARNING:tensorflow:Failed to load tensor2tensor

WARNING:tensorflow:From /Users/kishorekumarg/Desktop/venv/lib/python3.6/site-packages/tensor2tensor/models/research/glow_init_hook.py:25: The name tf.train.SessionRunHook is deprecated. Please use tf.estimator.SessionRunHook instead.

WARNING:tensorflow:From /Users/kishorekumarg/Desktop/venv/lib/python3.6/site-packages/tensor2tensor/models/research/neural_stack.py:38: The name tf.nn.rnn_cell.RNNCell is deprecated. Please use tf.compat.v1.nn.rnn_cell.RNNCell instead.

WARNING:tensorflow:From /Users/kishorekumarg/Desktop/venv/lib/python3.6/site-packages/tensor2tensor/rl/gym_utils.py:235: The name tf.logging.info is deprecated. Please use tf.compat.v1.logging.info instead.

WARNING:tensorflow:From /Users/kishorekumarg/Desktop/venv/lib/python3.6/site-packages/tensor2tensor/utils/trainer_lib.py:111: The name tf.OptimizerOptions is deprecated. Please use tf.compat.v1.OptimizerOptions instead.

WARNING:tensorflow:From /Users/kishorekumarg/Desktop/venv/lib/python3.6/site-packages/tensorflow_gan/python/estimator/tpu_gan_estimator.py:42: The name tf.estimator.tpu.TPUEstimator is deprecated. Please use tf.compat.v1.estimator.tpu.TPUEstimator instead.

Fitting 5 folds for each of 6 candidates, totalling 30 fits

[Parallel(n_jobs=1)]: Using backend SequentialBackend with 1 concurrent workers.

[Parallel(n_jobs=1)]: Done 30 out of 30 | elapsed: 2.5min finished

NLU model training completed.

Your Rasa model is trained and saved at '/Users/kishorekumarg/Desktop/models/20191124-210721.tar.gz.tar.gz'.

done

```

Now tried to test the same by passing a set of statement using the below code.

```
from rasa_nlu.model import Metadata, Interpreter

import json

# where `model_directory points to the folder the model is persisted in
interpreter = Interpreter.load('/Users/kishorekumarg/Desktop/models/20191124-210721.tar.gz')

```

The Error I have got is below.

`rasa_nlu.model.InvalidProjectError: Failed to load model metadata from '/Users/kishorekumarg/Desktop/models/20191124-210721.tar.gz/metadata.json'. [Errno 20] Not a directory: '/Users/kishorekumarg/Desktop/models/20191124-210721.tar.gz/metadata.json'`

My objective is to train a model in RASA Spacy\_sklearn as config and to test the same with set of statements as a kind of benchmarking activity. I am stuck with the below - can you please help me in this regard. I understand a lot has changed with rasa 0.14 to 1.4.6. Even for the training the model with python code - I have got the code from the rasa blog. It would be great if you could help on the testing the same model with python.

Thanks Kishore

---

<div class="post-metadata">

**Author:** ![kktowin](https://avatars.discourse-cdn.com/v4/letter/k/a183cd/32.png) [@kktowin](https://forum.rasa.com/u/kktowin)\
**Post date:** [December 2, 2019, 1:40am UTC](https://forum.rasa.com/t/rasa-1-4-6-python-code-to-train-test-manually/21707/2 "2019-12-02T01:40:11Z")

</div>

Any updates on the above please??

---

<div class="post-metadata">

**Author:** ![rohitnairtech](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/rohitnairtech/32/2100_2.png) [@rohitnairtech](https://forum.rasa.com/u/rohitnairtech)\
**Post date:** [March 18, 2020, 7:22am UTC](https://forum.rasa.com/t/rasa-1-4-6-python-code-to-train-test-manually/21707/3 "2020-03-18T07:22:45Z")

</div>

Were you able to fix it??

Can you suggest something?@souvikg10 @Emma @Juste

---

<div class="post-metadata">

**Author:** ![Juste](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/juste/32/15_2.png) [@Juste](https://forum.rasa.com/u/Juste)\
**Post date:** [March 18, 2020, 9:03am UTC](https://forum.rasa.com/t/rasa-1-4-6-python-code-to-train-test-manually/21707/4 "2020-03-18T09:03:18Z")

</div>

Hey @rohitnairtech. Which Rasa version are you running? I would suggest updating to the latest release - 1.8

---

<div class="post-metadata">

**Author:** ![rohitnairtech](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/rohitnairtech/32/2100_2.png) [@rohitnairtech](https://forum.rasa.com/u/rohitnairtech)\
**Post date:** [March 18, 2020, 9:16am UTC](https://forum.rasa.com/t/rasa-1-4-6-python-code-to-train-test-manually/21707/5 "2020-03-18T09:16:39Z")

</div>

Thanks for the reply @Juste I’m on 1.1.1.

However, I managed to fix the error by extracting the tar.gz and pointing to that directory. Agent.load("…/models/demo") Interpreter.load("…/models/demo/nlu")

I can’t upgrade to the latest version because of some issue from the latest tensorflow library which doesn’t support my CPU architecture.

---

<div class="post-metadata">

**Author:** ![kktowin](https://avatars.discourse-cdn.com/v4/letter/k/a183cd/32.png) [@kktowin](https://forum.rasa.com/u/kktowin)\
**Post date:** [April 8, 2020, 12:33pm UTC](https://forum.rasa.com/t/rasa-1-4-6-python-code-to-train-test-manually/21707/6 "2020-04-08T12:33:39Z")

</div>

I have installed RASA in an virtual environment it installs 1.5. Ideally its expected to install 1.8 or later now is 1.9. I have used the command as pip install rasa
