{"id":13901327,"url":"https://github.com/naskio/n8n-nodes-python","last_synced_at":"2025-04-07T17:07:49.129Z","repository":{"id":53332778,"uuid":"458153085","full_name":"naskio/n8n-nodes-python","owner":"naskio","description":"Run Python code on n8n","archived":false,"fork":false,"pushed_at":"2023-11-21T12:47:39.000Z","size":36,"stargazers_count":141,"open_issues_count":12,"forks_count":19,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T16:14:00.114Z","etag":null,"topics":["automation","n8n","n8n-nodes","n8n-nodes-python","python","python3","workflow"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/n8n-nodes-python","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/naskio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-02-11T11:07:44.000Z","updated_at":"2025-03-26T00:42:18.000Z","dependencies_parsed_at":"2024-01-16T22:22:07.907Z","dependency_job_id":"b48280a8-13fb-464d-b750-8801e527913e","html_url":"https://github.com/naskio/n8n-nodes-python","commit_stats":{"total_commits":28,"total_committers":6,"mean_commits":4.666666666666667,"dds":0.3214285714285714,"last_synced_commit":"fc09d596f98a109679e2f4686285a509d50d38c2"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naskio%2Fn8n-nodes-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naskio%2Fn8n-nodes-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naskio%2Fn8n-nodes-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naskio%2Fn8n-nodes-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/naskio","download_url":"https://codeload.github.com/naskio/n8n-nodes-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247694876,"owners_count":20980733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","n8n","n8n-nodes","n8n-nodes-python","python","python3","workflow"],"created_at":"2024-08-06T21:01:12.293Z","updated_at":"2025-04-07T17:07:49.091Z","avatar_url":"https://github.com/naskio.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# n8n-nodes-python\n\n![n8n.io - Workflow Automation](https://raw.githubusercontent.com/n8n-io/n8n/master/assets/n8n-logo.png)\n\nPythonFunction module - custom node for running python code on n8n.\n\n\u003e run python code on n8n\n\n# Python Function\n\nPythonFunction node is used to run custom Python snippets to transform data or to implement some custom functionality\nthat n8n does not support yet.\n\n# Installation\n\n## Using n8n-python Docker Image (Recommended)\n\nThis node is pre-installed in\nthe [n8n-python](https://github.com/naskio/docker-n8n-python) [docker image](https://hub.docker.com/r/naskio/n8n-python)\n.\n\n- Use `n8n-python:latest-debian` if you are planning to install heavy python packages such as `numpy` or `pandas`.\n- Use `n8n-python:latest` for a more lightweight image.\n\n\u003e Example using [docker-compose.yml](https://github.com/naskio/docker-n8n-python/blob/main/demo/docker-compose-local.yml)\n\n## Adding external packages\n\nYou can mount a `requirements.txt` file to the container to install additional packages.\n\nYou can use the [ExecuteCommand](https://n8n.io/integrations/n8n-nodes-base.executeCommand) node to\nrun `pip install -r requirements.txt`\nand the [n8nTrigger](https://n8n.io/integrations/n8n-nodes-base.n8nTrigger) node to trigger it after each **restart**.\n\n## Install Locally\n\n### 1- Install Requirements\n\nThis node requires the following dependencies to be installed in your environment:\n\n- Python 3.6 or higher\n\t```shell\n\tpython3 --version # check output version\n\t```\n\n- [python-fire](https://www.github.com/google/python-fire)\n\t```shell\n\t# install fire\n\tpip install fire\n\t```\n\n### 2- Add n8n-nodes-python to your n8n instance\n\nIf you’re running either by installing it globally or via PM2, make sure that you install `n8n-nodes-python` inside n8n.\nn8n will find the module and load it automatically.\n\nIf using docker, add the following line to your `Dockerfile`:\n\n```shell\n# Install n8n-nodes-python module\nRUN cd /usr/local/lib/node_modules/n8n \u0026\u0026 npm install n8n-nodes-python\n```\n\nRead more about the installation process in\nthe [n8n documentation - Use the n8n-nodes-module in production](https://docs.n8n.io/nodes/creating-nodes/create-n8n-nodes-module.html#use-the-n8n-nodes-module-in-production)\n.\n\n# Usage\n\nThis node receives `ìtems` and should return a list of `items`.\n\nExample:\n\n```python3\nnew_items = []\nfor item in items:\n\t\titem['newField'] = 'newValue'\n\t\tnew_items.append(item)\nreturn new_items # should return a list\n```\n\n\u003e The JSON attribute of each item is added and removed automatically.\n\u003e You can access the values directly without the `json` attribute.\n\u003e You don't need to put the item in a `json` attribute. it will be done automatically.\n\n## Variable: items\n\nthe `items` variable is a list of items that are passed to the function. They are directly accessible in the function.\n\nExample:\n\n```python3\nprint(items)\n# \u003e list\nreturn items\n```\n\n## Credentials: env_vars (optional)\n\nYou can specify environment variables to be used in the python code. The environment variables are accessible throw\nthe `env_vars` dict.\n\nExample:\n\n```python3\nprint(env_vars)\nprint(env_vars.get('MY_VAR','default_value'))\n# \u003e dict\n```\n\n## Logging to the browser console\n\nit is possible to write to the browser console by writing to `stdout`\n\nExample:\n\n```\nprint('Hello World')\n# or\nimport sys\nsys.stdout.write('Hello World')\n```\n\n# Notes\n\n- `stderr`is used for passing data between nodes.\n\n\t- if exit code is 0, the node will be executed successfully and `stderr` represents the JSON representation of the\n\t\toutput of the node\n\t- if exit code is not 0, the node fails and `stderr` represents the error message\n\n\n- The `json` attribute of each item is added and removed automatically. (you can access and return the items directly\n\twithout the `json` attribute)\n\n# Contribute\n\nPull requests are welcome! For any bug reports, please create an issue.\n\n# License\n\n[Apache 2.0 with Commons Clause](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaskio%2Fn8n-nodes-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnaskio%2Fn8n-nodes-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaskio%2Fn8n-nodes-python/lists"}