Python code blocks dont print

Describe the problem/error/question

When I run Python code node and print things to the console, nothing is printed in the console. I only see error messages or if something was returned it is returned there.

I copied the output of the HTML5 node into my local Python notebook and pretty quickly parsed the html in that environment however cannot for the life of me figure out what is happening in n8n because there is no console log.

What is the error message (if any)?

If I try returning something instead of printing it and it is not what n8n expects as the output then it doesnt show me what was actually returned which is very frustrating for debugging. I’m basically guessing what my output was when I get an error.

Please share your workflow

I have a Gmail trigger that pulls email data from a specific sender, specific HTML elements are selected with an HTML5 block and that HTML is returned in JSON format. Then I am trying to use a Python code block to parse this html data into a dataframe then into a structured json format.

Share the output returned by the last node

[
{
“$$flags”: 31
}
]

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:
1 Like

Hi @graham_vai, welcome to the community!

I am sorry you are having trouble.

When I run Python code node and print things to the console, nothing is printed in the console

I was very much surprised by this one as well, I could have sworn this worked in past previews. Even if not, this seems like a bug to me, so I’ve added this to the engineering team’s backlog for a closer look and a fix.

That said, when using print you would still see output in your server logs. So when running the below example workflow including print(...) you should see the output in your terminal:

image

Hope this is a suitable workaround for you. We’ll post an update on this thread once the issue has been fixed.

1 Like

Have the same issue. I also remeber it worked before. I am on n8n Cloud version.

This broke during our last pyodide upgrade, and will be fixed in this PR.

2 Likes

thank you for the reply!

New version [email protected] got released which includes the GitHub PR 6818.

1 Like

How to update to the newest version? I tried to update by clicking on the “1 Update” dialog box at the bottom left of the workflow screen, then click “How to update n8n” which brings me to a login screen when then brings me back to where I started?

That depends on how you have n8n deployed. Generally simply look for “update n8n” here in the forum.

Great, Thank you!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.