That will be a wonderful addition!
We are currently thinking about using a different library than the one I used in my above PoC. One that would be more secure. Sadly do not have an ETA yet. But I hope we can get it finished soon.
Hope to see it soon!
Welcome to the community @sackoh !
Actually good timing. Just finished around 2h ago upgrading the PoC to the new library. Looking good and is getting closer.
COOL!!!
@jan
I’m currently working on developing AI models and want to connect AI models deployed on local device or cloud with n8n
Python is my main programming language. I am waiting for your wonderful project!
Thanks for all you attending these!!
OK, the first beta version is ready to be tested.
Example command to start it:
docker run -it --rm --name n8n -p 5678:5678 -v ~/.n8n:/home/node/.n8n n8nio/n8n:PR-4295-python-code-node
There is now an additional setting in the Code-Node where Python
can be selected:
A few important things to consider:
- This is a beta. So there are probably still issues. It is also possible that things will change in the final production version. So workflows that get created now may not work in the production version without modifications.
- We did not do a security review yet. That means you should not give users you do not trust access to an n8n instance with this n8n version running.
- The Python editor is very basic. It only provides syntax highlighting but not the more fancy things like auto-complete or lining like the JavaScript version does.
Regarding usage
The variables that are available are identical between JavaScript and Python. But because of variable naming restrictions in Python do they not start with $
but rather with _
. So it is for example _input.all()
, _input.first().json
, _itemIndex
, _workflow
, and so on.
So give it a try and please share with us any feedback you have and problems you face. Also if you tried it, but did not face any issues and have no feedback. Then we know that one more person tested it, which is also an important data point.
Thanks a lot for your help and support!
This is huge
Nice to see that this is getting implemented! I need to get back into n8n and to all the stuff I planed to do.
Hi @jan ,
Two things I noticed:
- The node takes significantly longer time for its code to complete with python, than it’s javascript version.
- How can we add modules?
import requests
does not work.
Thanks a lot for giving it a try @Boris_Idesman and giving feedback. Is very appreciated.
- Yes, that is sadly expected and will always be the case as there is overhead running the Python code.
- 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 importcv2
viaimport 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 usen8nio/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.
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.
Apart from this I think the python node works very well - any ETA when it will be released?
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.
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.
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!!