Python Code gone after Update to v2.x

After the major version update (I’m on 2.3.6 now), my Python code is gone.

So when i go into a Code node which uses Python the “python” parameter is highlighted in red, as apparently the correct param value is “Python” now. The bad thing: When i select “Python” from the drop down I only see the code example and my initial Python logic code is gone.

As I had several nodes with Python code across workflows many of my workflows broke. Now I don’t n know where I can get the previous code from.

I use a Cloudron hosted instance, so I could try a rollback to a backup, but I would hope for a way to be able to transfer my pre-existing Python code in the nodes.

Only solution I see right now is to rollback to pre-update version, manually copy the code locally, update again, go over all WFs again and insert the disappeared Python code again. Feels very cumbersome.

I know that the Python code was always marked as Beta, but i would hope for a non-breaking update procedure in the release, without deleting my code.

Hi, there!

In n8n v2, existing Python code is not automatically migrated.

Selecting “Python” again initializes a new task runner with the default example code.

Unfortunately, there is currently no supported way to recover or auto-convert the old Python code after the upgrade. Restoring from a backup and re-adding the code manually is the only option.

This behavior is documented here:
https://docs.n8n.io/hosting/configuration/task-runners/

Wow!

Thanks for the reply. Fortunately I found a backup and was able to copy paste the Python code.

I would expect a more prominent warning about this behaviour.

1 Like

I think this is fixed in v2.5 as per:

1 Like

Thanks for the notice.

I’ll update then directly to this version.

1 Like

I made an account just to say that this was a terrible way to execute an upgrade from n8n. Even had there been a warning, there should have been some way to save the old code somewhere so I can figure out exactly what it is doing and make a new version.

Instead, the code is just deleted with no warning nor explanation and I basically have to rewrite an old automation (which has worked for years and years). Can’t imagine how annoying this is for people like OP who had more extensive python code than I did.

Very disappointing. It’s like n8n didn’t think through this at all. Lesson learned, export important automations periodically because n8n for sure doesn’t respect saving what already exists.

1 Like

Updated solution for Cloud users (like me):
Since downgrading the version is not possible, the support bot suggested:

You can try to recover your workflows by downloading your latest backup:

  1. Log in to your n8n Cloud dashboard.

  2. Navigate to the Admin Dashboard, then open the Manage section.

  3. Go to the Export tab and click ‘Download Workflows’ to retrieve your backup.

If your lost Python code is not recoverable via these backups and the upgrade resulted in data loss, please let us know so we can escalate your case to our support team for further assistance.

And it worked perfectly!

  • Navigate to a date before you updated the version.

  • Download all workflows

  • Select the json of the one you want to recover

  • Import in n8n as new flow. You can also drop it in your LLM of choice and extract from there but now n8n should be able to show the code even with the “python” issue.

Yeah migrating was painful for this one.

For Cloudron users: in future versions the update worked with the Python code being persistent, but the Python execution engine was gone. So also it’s not possible to use Python in the Cloudron setup (currently).
So ended up: restoring backup to save Python code, upgrade to newer n8n version, changing all Python code to JS…