Python module 'requests' not found error

I add python code node but I can’t run it. I have just added import requests, the node return an error:

ModuleNotFoundError: No module named 'requests' at PythonSandbox.getPrettyError

Information on your n8n setup

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

hello @tungn1027

python module does not support requests library. Use the HTTP requests node for that

But according to list of supported packages requests library is currently supportet by Pyodide. It should work, shouldn’t it?

As far as I get it, they are optional packages which should be loaded via pyodide.loadPackage()

Mmh, then I’m getting an error telling me pyodide has no attribute loadPackage.

I suppose it’s because they should be loaded from the backend side. So you can’t load any additional packages for pyodide. Just use the HTTP node for requests instead

Yes, using the HTTP node is my current workaround but since I’m migrating a python based backend to n8n it would be nice to just copy over my scraping functions without adapting them and splitting them up into multiple nodes.

1 Like

The confusion here is Pyodide added Requests from 0.25.0 and we use version 0.23.4 which doesn’t support it. I will see if we can get this updated at some point.

2 Likes

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