Import js throwing error

I have been playing around with pyscript examples. It all looks good when the example is in the repo itself but when I moved it out to it’s own repo, I started to see this error

JsException(PythonError: Traceback (most recent call last): File "/lib/python3.10/asyncio/futures.py", line 201, in result raise self._exception File "/lib/python3.10/asyncio/tasks.py", line 232, in __step result = coro.send(None) File "/lib/python3.10/site-packages/_pyodide/_base.py", line 500, in eval_code_async await CodeRunner( File "/lib/python3.10/site-packages/_pyodide/_base.py", line 351, in run_async coroutine = eval(self.code, globals, locals) File "",
line 1, in ImportError: cannot import name 'handTrack' from 'js' (unknown location) )

Are you also moving the handtrack javascript file out to the new location? The handtrack example expects to find handtrack.js (or handtrack.min.js) in the relative location lib/handtrack(.min).js, and the mario example expects to find it at ../handtrack/lib/handtrack(.min).js. Try copying the handtrack example to the same location as your examples.

If you’ve already done that, I would check where your html is trying to load handtrack.min.js from.

1 Like