Description
What happened?
I'm trying to configure pyscript-react using a pyscript_config.toml file which imports a python library file (geometry_generator.py) using [files]. It seems to load the config file but when I try to import from geometry_generator I get "ModuleNotFoundError: No module named 'geometry_generator'"
I have tried every different combination of file location and paths I can think of but I have not been able to load the geometry_generator file successfully. Currently it's located in public.
Below is the contents of my pyscript_config.toml file:
packages = ["svgwrite"]
[files]
"../geometry_generator.py" = "./geometry_generator.py"
Here is the relevant content of the page.tsx file where I use pyscript-react:
<PyScriptProvider>
<PyConfig
source="/pyscript_config.toml"
/>
<PyScript>
{`
from geometry_generator import *
`}
</PyScript>
</PyScriptProvider>
Version
0.0.4
Relevant log output
[pyexec] Python exception:
Traceback (most recent call last):
File "/home/pyodide/pyscript/_internal.py", line 104, in run_pyscript
result = eval_code(code, globals=__main__.__dict__)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lib/python311.zip/_pyodide/_base.py", line 468, in eval_code
.run(globals, locals)
^^^^^^^^^^^^^^^^^^^^
File "/lib/python311.zip/_pyodide/_base.py", line 310, in run
coroutine = eval(self.code, globals, locals)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<exec>", line 1, in <module>
ModuleNotFoundError: No module named 'geometry_generator'
app-index.tsx:25:19
error app-index.tsx:25
error hydration-error-info.ts:72
fn logger.ts:50
displayPyException pyexec.ts:64
pyExec pyexec.ts:36
init pyscript.ts:37
connectedCallback pyscript.ts:81
executeScripts main.ts:430
afterInterpreterLoad main.ts:279
loadInterpreter main.ts:254
_realMain main.ts:142
main main.ts:105
pyscript main.ts:457
<anonymous> pyscript.js:29204
How to reproduce?
Create Next.js project (using TypeScript), install pyscript-react and its dependencies, create a pyscript_config.toml file and include a python library file using [files] in the config file and try to import from that python library file in the python script within PyScript tags
Code of Conduct
- I agree to follow this project's Code of Conduct