Execute python file on N8n

Hi,

I have created a python script, Now I want to run that script in every hour. I can’t use Code node for that because my script is connected with other python scripts.

I want know about Execute Command node in n8n. I have hosted n8n locally.

  1. If I use Execute Command node, where Do I need to host my python files?

  2. How Can I my execution python code to execute my file.

Please someone help me with this.

  • n8n version: 1.42.1
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): Own
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Windows 11

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

Hi @AmilaDeshan

That’s a pretty interesting scenario you got there!

Given that you are using docker my first thought would be that you’d have to map the python directory to your docker container… But you might not have all the env options python needs to actually work and the modules path may be write protected as well… So you would probably be better off either using SSH to connect back to the host to run the Python or making a custom Dockerfile that includes python :thinking:
But I am no docker expert :see_no_evil:

Once you got the docker config set up though you can then connect a Schedule Trigger Node to your Execute Command Node and this should at least work from n8n side.

You just have to get your docker shell connected to your python scripts outside of the container.

See our Docs on the Execute Command Node:

Sorry I cannot be more specific on this as I have not really tried this myself.

But it would be really cool to see what you come up with! Do let us know how you get on! :raised_hands:

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