Python modules not being auto-installed

According to Code node documentation | n8n Docs, Python modules should be automatically installed:

n8n downloads the package automatically the first time you use it.

But instead it’s throwing an error:

What is the error message (if any)?

ModuleNotFoundError: No module named ‘pandas’ The module ‘pandas’ is included in the Pyodide distribution, but it is not installed. You can install it by calling: await micropip.install(“pandas”) in Python, or await pyodide.loadPackage(“pandas”) in JavaScript See  for more details.

Adding that await micropip.install(“pandas”) does not fix it either.

Stacktrace

Error: ModuleNotFoundError: No module named 'pandas' The module 'pandas' is included in the Pyodide distribution, but it is not installed. You can install it by calling: await micropip.install("pandas") in Python, or await pyodide.loadPackage("pandas") in JavaScript See https://pyodide.org/en/stable/usage/loading-packages.html for more details. at PythonSandbox.getPrettyError (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@aws-sdk+credential-providers@3.808.0_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/nodes/Code/PythonSandbox.ts:101:11) at PythonSandbox.runCodeInPython (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@aws-sdk+credential-providers@3.808.0_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/nodes/Code/PythonSandbox.ts:85:15) at runNextTicks (node:internal/process/task_queues:65:5) at processImmediate (node:internal/timers:453:9) at PythonSandbox.runCodeAllItems (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@aws-sdk+credential-providers@3.808.0_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/nodes/Code/PythonSandbox.ts:46:27) at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@aws-sdk+credential-providers@3.808.0_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/nodes/Code/Code.node.ts:168:14) at WorkflowExecute.runNode (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@opentelemetry+api@1.9.0_@opentelemetry+sdk-trace-base@1.29_46e522f8a77ed5eccc0991bfcca21502/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1212:9) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@opentelemetry+api@1.9.0_@opentelemetry+sdk-trace-base@1.29_46e522f8a77ed5eccc0991bfcca21502/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1582:27 at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@opentelemetry+api@1.9.0_@opentelemetry+sdk-trace-base@1.29_46e522f8a77ed5eccc0991bfcca21502/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:2158:11

Information on your n8n setup

  • n8n version: 1.105.4
  • Database: SQLite
  • n8n EXECUTIONS_PROCESS setting: default
  • Running n8n via Docker
  • Operating system: Windows 11

Hey @QSergi hope all is good. Welcome to the community.

You are taking this phrase out of context. The full version says

This limits the available Python packages to the Packages included with Pyodide. n8n downloads the package automatically the first time you use it.

It downloads the package [out of those included with Pyodide] when you first use it.

I think pandas is included in pyodide.

Ah it actually is, thank you for pointing this out. Just tried in my code node:

import pandas
print(pandas.__version__)
return []

Output in console:

[Node: "Code"] 2.2.3

So it actually doing everything that it supposed to - the first time I used it, the code ran for a good few seconds (obviously installing pandas), on the second run it ran in a split second.

Noice, you on self hosted or cloud?

Self hosted in Docker.

I figured out the issue. Because of company networking it was failing to validate the SSL cert when downloading the packages. I had to pass custom certs to the container to make it work.