No module named 'PyPulse' Error

Followed the appropriate steps in the Wiki to get Pulse working on PyCharm. Attempted to run a HowTo scenario and the following received the following error

Traceback (most recent call last):
File “C:\Windows\System32\Pulse\engine\src\python\pulse\howto\HowTo_AirwayObstruction.py”, line 7, in
from pulse.engine.PulseEngine import PulseEngine
File “c:\windows\system32\pulse\engine\src\python\pulse\engine\PulseEngine.py”, line 6, in
import PyPulse
ModuleNotFoundError: No module named ‘PyPulse’

Attempted to install PyPulse in the PyCharm package manager. I have also checked the bin location and have this file “PyPulse.cp39-win_amd64”

Unsure of what to do next to fix the errors shown.

I edit the Run/Debug Configuration of HowTo_AirwayObstruction.py and set the Working directory

Then I manually add these paths to my pycharm python interpreter (File->Settings)

If my working directory was not set, PyCharm could not find the PyPulse.cp39-win_amd64.pyd which give me the unable to find PyPulse… so I think setting that working directory should work

I set the working directory to install\bin as well as added the same paths into the into the pycharm python interpreter. Same error occurred. Currently using Python 3.11, if that may help diagnose the issue further.

Since you built pulse with python 3.9
You need to run a 3.9 interpreter in PyCharm
Those have to match

Interpreter is now Python 3.9, but same error is occurring. All else appears to be equal when comparing screenshots

What branch are you building?

I actually think building my environment is where an issue is occurring now. After reinstalling Python 3.9 the code ran on PyCharm, but failed to find the initial state. I checked the files and some files were missing that were in my original attempt to build the environment

States are genereated during the superbuild See here for regeneration of states

If your build did not finish or you don’t have the expected files in your install/bin, you will also need to generate data via run genData before you run genStates

More on our run script can be found here

I believe built the environment successfully into PyCharm as I am able to run the HowTo files successfully. However, trying to make our own code in the HowTo, it fails to find the initial state. I also receive this error

Traceback (most recent call last):
File “C:\Programming\Pulse\engine\src\python\pulse\howto\Test.py”, line 50, in
print(results[‘MeanArterialPressure (mmHg)’][0])
KeyError: ‘MeanArterialPressure (mmHg)’

The written code was running in the Jupyter notebook, as that was where it was created. The only thing done was copying and pasting it over to PyCharm

Make sure you set the working directory in the configuration
Pulse is looking for files relative to the working directory

Are you refering to a Jupyter notebook we created?

It sounds like pulse.serialize_from_file or pulse.initialize_engine was not successful

Are you sure you requested MeanArtierialPressure from pulse via a data request manager?

Working directory is set to install\bin and works when it is set to this directory, any other directory causes the PyPulse error.

Yes the code was written in the Jupyter notebook that was create. It may be usual to mention the the script written was inside the “HowTo_EngineUse” Notebook in Jupyter.

MeanArterialPressure was requested with SEDataRequestManager following the required format

If you want to run from any other working directory, you should add the folder that conatins the PyPulse.pyd file to your PYTHONPATH

You don’t need to do that if you set the working directory to a folder with PyPulse.pyd

Got it working now! The Jupyter notebook code brought the state from /data/…, there was no /data/ needed in the local Python as that folder didn’t exist. It was copied and pasted over so once the /data/ filepath portion was removed, the initial state was successfully loaded.

Awesome!