n8n - 💡(How to fix) Fix Python built-in lib error: mappingproxy' object has no attribute 'import' [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
n8n-io/n8n#29745Fetched 2026-05-06 06:35:25
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×3commented ×1mentioned ×1subscribed ×1

Error Message

{ "nodes": [ { "parameters": {}, "type": "n8n-nodes-base.manualTrigger", "typeVersion": 1, "position": [ -1248, -1072 ], "id": "4be1dc93-82cc-4162-8f3e-e074e48c32ae", "name": "When clicking ‘Execute workflow’" }, { "parameters": { "language": "pythonNative", "pythonCode": "import traceback\nfrom datetime import datetime\n\ntry:\n s = "01.01.2000 14:30"\n dt = datetime.strptime(s, "%d.%m.%Y %H:%M")\n iso = dt.isoformat()\nexcept Exception:\n return [{"json": {"data": traceback.format_exc()}}]\n\nreturn [{"json": {"data": None}}]" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ -1024, -1072 ], "id": "45501b6a-b7e3-4012-a41b-5ac0be7d9959", "name": "Code in Python" } ], "connections": { "When clicking ‘Execute workflow’": { "main": [ [ { "node": "Code in Python", "type": "main", "index": 0 } ] ] } }, "pinData": {}, "meta": { "templateCredsSetupCompleted": true, "instanceId": "ae8cd1c0f8a5664e6d74f12084bf9027051d96efbc027ab983b556b365264096" } }

Code Example

{
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -1248,
        -1072
      ],
      "id": "4be1dc93-82cc-4162-8f3e-e074e48c32ae",
      "name": "When clicking ‘Execute workflow’"
    },
    {
      "parameters": {
        "language": "pythonNative",
        "pythonCode": "import traceback\nfrom datetime import datetime\n\ntry:\n  s = \"01.01.2000 14:30\"\n  dt = datetime.strptime(s, \"%d.%m.%Y %H:%M\")\n  iso = dt.isoformat()\nexcept Exception:\n  return [{\"json\": {\"data\": traceback.format_exc()}}]\n\nreturn [{\"json\": {\"data\": None}}]"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -1024,
        -1072
      ],
      "id": "45501b6a-b7e3-4012-a41b-5ac0be7d9959",
      "name": "Code in Python"
    }
  ],
  "connections": {
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Code in Python",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "ae8cd1c0f8a5664e6d74f12084bf9027051d96efbc027ab983b556b365264096"
  }
}

---

[
  {
    "data": null
  }
]
RAW_BUFFERClick to expand / collapse

Bug Description

Hello! I were using datetime lib in python and got error "'mappingproxy' object has no attribute 'import'" while using datetime.strptime function.

To Reproduce

Run this workflow:

{
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -1248,
        -1072
      ],
      "id": "4be1dc93-82cc-4162-8f3e-e074e48c32ae",
      "name": "When clicking ‘Execute workflow’"
    },
    {
      "parameters": {
        "language": "pythonNative",
        "pythonCode": "import traceback\nfrom datetime import datetime\n\ntry:\n  s = \"01.01.2000 14:30\"\n  dt = datetime.strptime(s, \"%d.%m.%Y %H:%M\")\n  iso = dt.isoformat()\nexcept Exception:\n  return [{\"json\": {\"data\": traceback.format_exc()}}]\n\nreturn [{\"json\": {\"data\": None}}]"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -1024,
        -1072
      ],
      "id": "45501b6a-b7e3-4012-a41b-5ac0be7d9959",
      "name": "Code in Python"
    }
  ],
  "connections": {
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Code in Python",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "ae8cd1c0f8a5664e6d74f12084bf9027051d96efbc027ab983b556b365264096"
  }
}

Expected behavior

Get this json in output

[
  {
    "data": null
  }
]

Debug Info

Debug info

core

  • n8nVersion: 2.18.5
  • platform: docker (self-hosted)
  • nodeJsVersion: 24.14.1
  • nodeEnv: production
  • database: postgres
  • executionMode: scaling (single-main)
  • concurrency: -1
  • license: enterprise (production)
  • consumerId: cd3ca1ce-4948-472b-9b6a-baaaff7ec99f

storage

  • success: all
  • error: all
  • progress: false
  • manual: true
  • binaryMode: database

pruning

  • enabled: true
  • maxAge: 336 hours
  • maxCount: 10000 executions

client

  • userAgent: mozilla/5.0 (macintosh; intel mac os x 10_15_7) applewebkit/537.36 (khtml, like gecko) chrome/147.0.0.0 safari/537.36
  • isTouchDevice: false

security

  • blockFileAccessToN8nFiles: false

Generated at: 2026-05-05T05:04:01.569Z

Operating System

Debian 6.1.133-1

n8n Version

2.18.5

Node.js Version

24.14.1

Database

PostgreSQL

Execution mode

queue

Hosting

self hosted

extent analysis

TL;DR

The issue is likely due to a compatibility problem between the Python version used in the n8n node and the datetime library, causing the 'mappingproxy' object has no attribute 'import' error.

Guidance

  • The error suggests that there's an issue with how the datetime library is being imported or used within the n8n workflow, possibly due to changes in Python's import mechanism or the library itself.
  • Verify that the Python version used by the n8n node supports the datetime library as expected. Given the Node.js version (24.14.1) and n8n version (2.18.5), ensure compatibility with the Python environment.
  • Check the n8n documentation for any specific requirements or recommendations for using Python scripts, especially regarding library imports and versions.
  • Consider testing the Python script outside of the n8n environment to isolate if the issue is specific to n8n's execution of Python code.

Notes

The provided information does not specify the Python version being used, which could be crucial for diagnosing the issue, as different Python versions have different import mechanisms and library support.

Recommendation

Apply workaround: Test the Python script in a standalone environment to confirm if the issue is n8n-specific or a general Python compatibility problem. This can help in identifying whether the problem lies in the n8n setup or the Python code itself.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Get this json in output

[
  {
    "data": null
  }
]

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING