We have some Python files that we would like to run on a regular basis, and I was thinking of using n8n for this: A Cron node followed by an Execute command node to run a specific Python file.
Is this possible, and if so does anyone have any insights that could help us deploy such a solution? We have deployed n8n on Heroku, maybe there are some specifics? Such as how to install Python and all necessary libraries.
Also, once we have the Python file that we have developed locally, should we use an FTP to send it to our n8n database or can this be done directly via n8n?
Hi @maximp , that’s totally doable as you can see in the screenshot. Basically the execute command node is a bash instance where you can execute any available command.
To achieve what you are aiming for, you need to have python installed on your instance with the required libraries you will be using.
Also you can use the execute command node to install them, just make sure you have the right user (with the right privileges) when starting then n8n instance.
Concerning the files, it is better to save them directly on the file system, rather than using n8n database, also you can use a combination of FTP and writeBinaryFile node to retrieve and save the files before executing them.
Yes, @chris! The docker-compose file just describes how what docker images to use and with what parameters. So you would do exactly what I did explain above and then change the docker-image you use in the docker-compose file.
After I successfully install the library again with pip3 install requests in an execute command node, I get the following warning,
WARNING: The script normalizer is installed in '/home/node/.local/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. WARNING: You are using pip version 21.1.1; however, version 21.3.1 is available. You should consider upgrading via the '/usr/bin/python3.8 -m pip install --upgrade pip' command.
Have you throught about using a requirements file that you load in your docker file to install the modules needed when the container is built? Could be easier and more familiar if you know your way around Python.
Is there a way to get some custom data from previous node and give that as a input to this python node, to transform the data and then later output it to other node ?
I cant find any node in n8n that would support advanced data transformation , like pandas , or once the data is fetched from diff source, no sql like query option to transform that data to my liking.
I was thinking if i can do this in python