# Python API 4.x - Issues with loading initial state file

**URL:** https://discourse.kitware.com/t/python-api-4-x-issues-with-loading-initial-state-file/950
**Category:** Pulse Physiology Engine
**Created:** [December 14, 2022, 7:50pm UTC](https://discourse.kitware.com/t/python-api-4-x-issues-with-loading-initial-state-file/950 "2022-12-14T19:50:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![joe](https://discourse.kitware.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://discourse.kitware.com/u/joe)
#### Post date: [December 14, 2022, 7:50pm UTC](https://discourse.kitware.com/t/python-api-4-x-issues-with-loading-initial-state-file/950/1 "2022-12-14T19:50:34Z")

</div>

Hello,

I am trying to use **Python Pulse Engine 4.x** on **Ubuntu** , however I am getting the following error: **Unable to load initial state file** whenever I run any of the How To python scripts.

Here’s what I’ve done so far:

I’ve ran cmake-gui (version 3.16.3) with full file path of Pulse/engine/ for the source code location and full file path for Pulse/builds/Release for the location for building binaries. Download\_Baselines, Java API, Python API, Superbuild, and Use Git Protocol are all selected. Pressed Configure and Generate.

I’ve run make -j4

PYTHONPATH has been updated with the full file paths for engine/src/python/, builds/Release/Innerbuild/src/python/, and builds/Release/install/bin/

I verified that builds/Release/install/python/pulse/cdm/bind/ is populated with \_pb2 scripts.

In PyCharm, I added full paths of engine/src/python/, builds/Release/Innerbuild/src/python/, and builds/Release/install/bin/ to the interpreter paths

In Pycharm Run/Debug Config, I changed the Python template working directory to full path of builds/Release/install/bin/

I have Python 3.8.10

However, when I run HowTo\_AcuteStress . py, I get 5 INFO lines (Serializing from file, Human Adult Whole Body, etc) and then Unable to load initial state file

Is there a step I missed?

Thanks

---

<div class="post-metadata">

### Author: ![abray](https://discourse.kitware.com/user_avatar/discourse.kitware.com/abray/32/12_2.png) [@abray](https://discourse.kitware.com/u/abray)
#### Post date: [December 15, 2022, 2:03pm UTC](https://discourse.kitware.com/t/python-api-4-x-issues-with-loading-initial-state-file/950/2 "2022-12-15T14:03:42Z")

</div>

Hi @joe

It looks like the issue may be that in the HowTo example files I am having them serialize in a pbb (protobuf binary file) `"./states/Soldier@0s.pbb"`  
The data generation script (`./run.sh genData`) in pulse used to generate both json and pbb files used to get generated by the pulse build  
But, I have made a change that resulted in only the json files getting generated.  
I pushed up changes to update all the python examples that load states, to load json states  
I believe just pulling that or updating your code to serialize a json (`if not pulse.serialize_from_file("./states/Soldier@0s.json", None):`) file rather than a pbb file should fix you up.

If not, let me know!

Thanks!

---

<div class="post-metadata">

### Author: ![joe](https://discourse.kitware.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://discourse.kitware.com/u/joe)
#### Post date: [January 4, 2023, 9:08pm UTC](https://discourse.kitware.com/t/python-api-4-x-issues-with-loading-initial-state-file/950/3 "2023-01-04T21:08:17Z")

</div>

Hi @abray ,

Your advice worked, thank you. However, I did run into some other issues. HowTo\_AcuteStress runs fine, however HowTo\_Anemia eventually throws “number of data requests does not match the number of tracked properties!” and “Unable to load stabilize engine.” For whatever reason, it looks like TotalFluid\_ml is being tracked but is not being requested.

Another issue is regarding a custom script. I first ran the script in a notebook in the Pulse Binder environment to make sure it is working. I then moved the script to PyCharm where I also modified the paths. However, pulse.initialize\_engine seems to be failing as I get Unable to Load Stabilize engine.

Thanks

---

<div class="post-metadata">

### Author: ![abray](https://discourse.kitware.com/user_avatar/discourse.kitware.com/abray/32/12_2.png) [@abray](https://discourse.kitware.com/u/abray)
#### Post date: [January 5, 2023, 2:08pm UTC](https://discourse.kitware.com/t/python-api-4-x-issues-with-loading-initial-state-file/950/4 "2023-01-05T14:08:11Z")

</div>

Our binder space is not up to date, its still pretty old  
I don’t have an automated build step to create and publish a docker container for our binder space.

It looks like TotalFluid\_ml is being tracked due to [me leaving in a hard coded data track](https://gitlab.kitware.com/physiology/engine/-/blob/cbb22ce5c8ff835d022c921ff49a423d0369e9bf/src/cpp/engine/common/system/physiology/TissueModel.cpp#L1169) when investigating an issue

I just pushed this fix up to 4.x, that looks like the culprit to the miss match in the number of data request numbers

So that should get you moving again!
