Python node [GOT CREATED]

Thanks a lot for giving it a try @Boris_Idesman and giving feedback. Is very appreciated.

  1. Yes, that is sadly expected and will always be the case as there is overhead running the Python code.
  2. Played around some more and made some modifications. Please pull the same image again from dockerhub to get the latest version. It includes now a parameter called “Python Module”. There you can enter the names of the modules that should be able to be imported. We will iterate how we want to solve that long-term. So you can for example type in opencv-python that you can then import cv2 via import cv2. Be however aware, that you can only import modules that you installed before (if there are non standard ones). So if you want to use opencv, you first have to install it via pip. So you would need a custom image. If you want you could use n8nio/n8n:PR-4295-python-code-node as the base.

Also important to mention is that n8n uses pyodide underneath the hood. You can find more information about loading packages here.

4 Likes

Hi @Boris_Idesman ,
I’m also struggling with importing requests and other packages.

Thanks to the @jan 's mention about n8n uses pyodide, I can figure out why I cannot import it.
you can refer this.

and packages supported by pyodide only could be used at this moment I figured out.

2 Likes

Apart from this I think the python node works very well - any ETA when it will be released?

1 Like

Hello there,
Is there any news on the release date?

It will officially be released end of June with n8n v1.0. It will, however, probably already be merged within the next 1-2 weeks but will only be available if a special v1-pre-release environment variable gets set. That gives us some time to test its quality, stability and security.

4 Likes

Hello jan,
I have opened a topic about no-standard library for Python.

Can you just give me information how to add custom library ? Because it’s not knew for n8n ?
Thank you

Hi @jan,

Thanks to keep us informed.

In which version it will be provided ? I can’t found any “python” in the release changelogs.
I’m currently facing many performance issue using the naskio python node. It would be great if I can have a try on a (almost) stable version of your official python node code. I’ll be able to provide you feedbacks

The code got merged last week and it will be released with the next version ([email protected]) on Wednesday. But as mentioned, will it not be available by default. One way to use it would then be to copy a Code-Node in a Text-Editor, manually change the typeVersion to 2, copy it the Node-JSON, and then paste it into n8n.

We are also in the process of releasing the first v1 release candidates, which will have it enabled by default (so it will always create Code-Nodes of version 2). Those images will be auto-generated every night and named: docker.n8n.io/n8nio/n8n:1.0.0-rc. That will however take probably another 1-3 days.

2 Likes

fyi: The image is now available.

Thrilled to see this officially being added. I’ve been using my own fork of @naskdev ‘s image for a while now, so it’ll be nice to have it officially added. Thanks for everybody’s hard work on this!!

1 Like

Python support is now in the main release (although hidden by default): Python Support and Release Versions

3 Likes

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

Hello! I think I may have found a bug in the new Python code node, where Python code is not saved once the configuration dialog is dismissed.

When I edit Python code, then press Escape or otherwise dismiss the configuration dialog, and then open it again, the field that holds the source code is reset to the sample Python code.

I have managed to reproduce it in two completely separate N8N instances, both running v0.228.2 on Docker. It only happens when using the Code node with typeVersion set to 2 and Language set to Python (Javascript with typeVersion 2 is not affected)

Would you like me to post more detailed reproduction steps here, or on a new thread, or as a Github issue? It should be really easy to reproduce: create a Python code node, edit it (say, delete the comment on the first line), close and reopen the dialog, the comment should be back.

As an aside: that’s a really neat functionality, thank you! Adding Python scripts should really extend the range of people that can easily pick up N8N.

Hey @jreyesr,

Can you open a new thread for it and complete the template with the detailed steps.

New thread is here.
Thank you for your help!

i was just testing docker v1.0.2 with the python code functionality.

It doesn’t seem to have simple modules like “requests”

ERROR: ModuleNotFoundError: No module named 'requests'

any ideas on how to get these added/supported?

Hey @RedPacketSec,

The modules are limited to whatever has been submitted to Pyodide, You can find the list here: https://github.com/pyodide/pyodide/tree/0.22.1/packages

I guess if you wanted Requests added / supported the maintainers for requests would need to submit it.

1 Like

Good news, The Python node was released with 1.0. I am going to move this to the done category so that you can all have your vote back :slight_smile:

are there going to be improvements for this functionality?
As the python library used is so restrictive when using docker and not having full python ability to pull modules in.

Ive had to revert back to SSHing to a linux box doing the python there dumping to a json file and pulling that back in.

Hey @RedPacketSec,

There may be improvements over time and of course as Pyodide improves we get those changes as well.