Aria rasa_run fails with message Could not load model due to 'str' object has no attribute 'decode'.
search cancel

Aria rasa_run fails with message Could not load model due to 'str' object has no attribute 'decode'.


Article ID: 204653


Updated On:


CA Service Desk Manager


Experiencing the following error during an initial attempt to install Rasa.  After completing rasa_train, during the rasa_run command:

2020-01-01 00:00:45 ERROR    rasa.core.agent  - Could not load model due to 'str' object has no attribute 'decode'.

[2020-01-01 00:00:45 -0800] [10344] [ERROR] Experienced exception while trying to serve
Traceback (most recent call last):
  File "c:\aria\botenv\lib\site-packages\sanic\", line 1192, in run
  File "c:\aria\botenv\lib\site-packages\sanic\", line 912, in serve
    trigger_events(before_start, loop)
  File "c:\aria\botenv\lib\site-packages\sanic\", line 668, in trigger_events
  File "C:\ProgramData\Anaconda3\lib\asyncio\", line 584, in run_until_complete
    return future.result()
  File "c:\aria\botenv\lib\site-packages\rasa\core\", line 253, in load_agent_on_start
  File "c:\aria\botenv\lib\site-packages\rasa\core\", line 271, in load_agent
  File "c:\aria\botenv\lib\site-packages\rasa\core\", line 938, in load_local_model
  File "c:\aria\botenv\lib\site-packages\rasa\core\", line 394, in load
    ensemble = PolicyEnsemble.load(core_model) if core_model else None
  File "c:\aria\botenv\lib\site-packages\rasa\core\policies\", line 256, in load
    policy = policy_cls.load(policy_path)
  File "c:\aria\botenv\lib\site-packages\rasa\core\policies\", line 259, in load
    model = load_model(model_file)
  File "c:\aria\botenv\lib\site-packages\tensorflow_core\python\keras\saving\", line 146, in load_model
    return hdf5_format.load_model_from_hdf5(filepath, custom_objects, compile)
  File "c:\aria\botenv\lib\site-packages\tensorflow_core\python\keras\saving\", line 166, in load_model_from_hdf5
    model_config = json.loads(model_config.decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'



CA Service Management 17.3


The initial command used to create the environment was incorrectly performed.


The original command to create the given environment in Python that would cause this issue would have been:

python -m venv ./botenv

The correct command to use is:

python -m venv --system-site-packages ./botenv

The above error happens as the "--system-site-packages" was left out.  Including this parameter ensures that the library versions included with Anaconda out-of-the-box will be chosen over any new installation of libraries from rasa installation.

Additional Information

The specific library that is causing the issue is h5py.  The version of the library installed OOTB with Anaconda is 2.9.0 and the version of library that will be installed when running pip install rasa is 3.1.0. By using the flag system-site-packages we are effectively asking the environment to ignore any new installations of the libraries as the base environment already satisfies this requirement. If the flag isn't used, the new environment (botenv) doesn't care about what is installed in the base environment and installs the version 3.1.0 and uses it. This new version of the library has some enhancements and code changes that breaks the existing functionality of the RASA server.