PFython / pyscript-local-runtime

164 stars 38 forks source link

Use package #6

Open tommarekCZE opened 9 months ago

tommarekCZE commented 9 months ago

Hello, how I can import like package by import, I saw I must use pyscript.json, but I dont know where to put that or is there any other method. Thanks.

tommarekCZE commented 9 months ago

I tried excatly tihs: image

but it didnt works too.

t2solve commented 6 months ago

At first a really love your nice example. It solved my offline usage problem. I also tried to load packages, but failed somehow, I also put the wheel file into the runtime folder , but still I get an error.

Here is what i tried to add runtime/matplotlib-3.8.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl following the docs: pyscript conig Here my changes the py-config tag in popup.html

 <py-config>
      [[runtimes]]
      src = "runtime/pyodide.js"
      name = "pyodide-0.21.3"
      lang = "python"
      [packages] 
      src = "runtime/matplotlib"
      name = "matplotlib-3.8.2"
      lang = "python"

 </py-config>

brings me to the following error: 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 506, in eval_code_async await CodeRunner( File "/lib/python3.10/site-packages/_pyodide/_base.py", line 357, in run_async coroutine = eval(self.code, globals, locals) File "", line 1, in ModuleNotFoundError: No module named 'matplotlib'

Also my python server call

python3 -m http.server 8080

shows me the hint: the wheel package is never delivered ?

Serving HTTP on 0.0.0.0 port 8080 (http://0.0.0.0:8080/) ...
127.0.0.1 - - [24/Jan/2024 09:26:20] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [24/Jan/2024 09:26:21] code 404, message File not found
127.0.0.1 - - [24/Jan/2024 09:26:21] "GET /favicon.ico HTTP/1.1" 404 -
127.0.0.1 - - [24/Jan/2024 09:26:22] "GET /popup.html HTTP/1.1" 200 -
127.0.0.1 - - [24/Jan/2024 09:26:22] "GET /popup.css HTTP/1.1" 304 -
127.0.0.1 - - [24/Jan/2024 09:26:22] "GET /runtime/pyscript.css HTTP/1.1" 304 -
127.0.0.1 - - [24/Jan/2024 09:26:22] "GET /runtime/pyscript.js HTTP/1.1" 304 -
127.0.0.1 - - [24/Jan/2024 09:26:22] "GET /runtime/pyodide.js HTTP/1.1" 304 -
127.0.0.1 - - [24/Jan/2024 09:26:22] "GET /runtime/pyodide_py.tar HTTP/1.1" 304 -
127.0.0.1 - - [24/Jan/2024 09:26:22] "GET /runtime/pyodide.asm.js HTTP/1.1" 304 -
127.0.0.1 - - [24/Jan/2024 09:26:22] "GET /runtime/pyodide.asm.data HTTP/1.1" 304 -
127.0.0.1 - - [24/Jan/2024 09:26:22] "GET /runtime/repodata.json HTTP/1.1" 304 -
127.0.0.1 - - [24/Jan/2024 09:26:22] "GET /runtime/pyodide.asm.wasm HTTP/1.1" 304 -
127.0.0.1 - - [24/Jan/2024 09:26:24] "GET /runtime/pyparsing-3.0.9-py3-none-any.whl HTTP/1.1" 304 -
127.0.0.1 - - [24/Jan/2024 09:26:24] "GET /runtime/micropip-0.1-py3-none-any.whl HTTP/1.1" 304 -
127.0.0.1 - - [24/Jan/2024 09:26:24] "GET /runtime/distutils.tar HTTP/1.1" 304 -
127.0.0.1 - - [24/Jan/2024 09:26:24] "GET /runtime/packaging-21.3-py3-none-any.whl HTTP/1.1" 304 -
127.0.0.1 - - [24/Jan/2024 09:26:27] code 404, message File not found
127.0.0.1 - - [24/Jan/2024 09:26:27] "GET /runtime/pyscript.js.map HTTP/1.1" 404 -
127.0.0.1 - - [24/Jan/2024 09:26:27] code 404, message File not found
127.0.0.1 - - [24/Jan/2024 09:26:27] "GET /runtime/pyodide.js.map HTTP/1.1" 404 -

Maybe somebody could give me a hint, should i focus more on the a) micropip-0.1 package or b) copy the files to the inside py-config tags e.g.

[files]
"https://example.com/data.csv" = "./data.csv"
"/code.py" = "./subdir/code.py"