pyodide: pyodide - requests module is not available

Any chance you’ll add this? I’m looking to bring in data from Google Sheets.

Error: Traceback (most recent call last):
  File "/lib/python3.7/site-packages/pyodide.py", line 42, in eval_code
    exec(compile(mod, '<exec>', mode='exec'), ns, ns)
  File "<exec>", line 3, in <module>
ModuleNotFoundError: No module named 'requests'

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 15
  • Comments: 16 (11 by maintainers)

Most upvoted comments

How about something like this:

import json
from js import window

print(
    window.fetch("https://jsonplaceholder.typicode.com/todos/1")
    .then(lambda response: response.text())
    .then(lambda data: print(json.dumps(json.loads(data), indent=4)))
)

urllib3 2.2.0 supports Pyodide: https://urllib3.readthedocs.io/en/stable/reference/contrib/emscripten.html. Which means requests supports it too.

Yes, thanks. I think we should add a redirect=‘follow’ default argument and pass it to JS fetch.