Pyscript + Jupyter: not seeing logs

Hello,
I’m new to Pyscript and Jupyter, and I just installed it all to give it a try. I did the following:

  • Installed Pyscript via HACS
  • Configured Pyscript Integration and restarted Home Assistant Core
  • Installed Python 3.9 via Homebrew on my Mac
  • Installed hass_pyscript_kernel and jupyterlab via pip3 command
  • Ran jupyter pyscript install and jupyter lab build

After this I downloaded the Pyscript tutorial notebook and opened it both via jupyter and jupyter-lab.

According to the documentation, I should see the result of log calls directly inline within the notebook. I’m not able to see them however.

As you can see in this screenshot there is no log output beneath the cell even after running the cell.

I’ve verified that Pyscript is running correctly by running the service registration example shown later in the notebook and verifying that a service was registered in HomeAssistant.

What am I doing wrong?

Where did you find pyscript?

image

I have exactly this problem. Did you manage to solve it ever?

You must use “debug” as logging level in Logger for getting log output. In the configuration.yaml paste this:

logger:
  default: info
  logs:
    custom_components.pyscript: debug

In a pyscript file you can use log.debug(str) for logging a message instead of print(str).
It is already a Issue in github about more logging documentation Suggestion to add info on logging levels · Issue #265 · custom-components/pyscript · GitHub

2 Likes

Great thanks! Completely missed this in the docs.

4 Likes

Thanks, saved me hours. I am not using Jupyter, but could not see any debugging statements from Pyscript, in the form log.info("....") with custom_components.pyscript: info in configuration.yaml. All that worked perfectly outside Docker container.