Is local module import broken?

I was having trouble importing local modules, getting a “ModuleNotFoundError.” Sure that I was setting up py-config correctly, I copied and pasted the example scripts from the documentation (see below) and got the same error. Is this a known issue or is it a matter of the documentation lagging behind the latest version a bit?

import numpy as np
def make_x_and_y(n):
    x = np.random.randn(n)
    y = np.random.randn(n)
    return x, y
      <link rel="stylesheet" href="" />
      <script defer src=""></script>

    <h1>Let's plot random numbers</h1>
    <div id="plot"></div>
    <py-config type="toml">
        packages = ["numpy", "matplotlib"]

        files = ["./"]
    <py-script output="plot">
      import matplotlib.pyplot as plt
      from data import make_x_and_y
      x, y = make_x_and_y(n=1000)
      fig, ax = plt.subplots()
      ax.scatter(x, y)

When loading the page, this error is printed

“PythonError: Traceback (most recent call last): File “/lib/python3.10/asyncio/”, line 201, in result raise self._exception File “/lib/python3.10/asyncio/”, line 232, in __step result = coro.send(None) File “/lib/python3.10/site-packages/_pyodide/”, line 506, in eval_code_async await CodeRunner( File “/lib/python3.10/site-packages/_pyodide/”, line 357, in run_async coroutine = eval(self.code, globals, locals) File “”, line 2, in ModuleNotFoundError: No module named ‘data’”

Hi Mark,

Unfortunately it’s our documentation that is broken, not local module import. Right now, we update whenever new docs get merged into the GtiHub repo, but those changes aren’t available in a release until…well, until the next release.

At this exact moment (in 2022.09.1), the syntax to load files from a URL into the Emscirpten file system is:

  paths = ['']

Which will load the resource at the relative URL “” to the local path “./”

The doc issue is unfortunate - especially with the number of great-but-breaking changes recently. It’s being tracked as #937 on GitHub, and we hope to have a resolution soon.

I would expect that’s just the nature of the beast when you’re developing a framework in ‘real time’. I appreciate the work you and the other maintainers have put into this and thanks for the info on imports.