Skip to content

Node support #27

@prescod

Description

@prescod

Please document whether Node is supported and if so, please provide an example. This example failed for me:

const { loadPyodide } = require("pyodide");

async function hello_python() {
  let pyodide = await loadPyodide();
  await pyodide.loadPackage("micropip");
  const micropip = pyodide.pyimport("micropip");
  await micropip.install("requests");
  return pyodide.runPythonAsync(`
  # 1. Install this package
  import micropip
  await micropip.install('pyodide-http')
  
  # 2. Patch requests
  import pyodide_http
  pyodide_http.patch_all()  # Patch all libraries
  
  # 3. Use requests
  import requests
  response = requests.get('http://www.google.com/')
  `);
}

hello_python().then((result) => {
  console.log("Python says that the lineup is", result);
});

Node.js v18.12.1

Error:

: Failed to establish a new connection: [Errno 50] Protocol not available'))

Or with https:

Can't connect to HTTPS URL because the SSL module is not available.

Versions:

        "fs": "^0.0.1-security",
        "node-fetch": "^3.3.0",
        "pyodide": "^0.21.3"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions