You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I enjoyed and was able to build this example Chrome extension that uses pyscript. Too cool! I use Firefox, and I know a modest bit of python but nearly no JavaScript, so I was interested in making my first-ever Firefox extension with pyscript (starting with just a hello world).
I was hoping to do something similar to a mashup of the project above and the Mozilla extension quickstart, for which I'd be using pyscript directly in the javascript part of the extension, perhaps via pyscript.runtime.interpreter.runPython, instead of being loaded in index.html.
Unfortunately I haven't been able to get it to work. I'm very new to JavaScript, but from what I can tell the issue is that pyscript can't find the local runtime/pyodide; I set this in py-config as done here, but JavaScript is going to be operating in the context of the webpage it is running on, so it looks for that as a local path from the webpage.
Failed to get subsystem status for purpose
Object { rejected: true, message: TypeError }
[content-script.js:95:21](moz-extension://fe9afcad-4e01-43b8-9f04-8e07fd85ee54/content-script.js)
[pyscript/main] searching for <py-config> [pyscript.js:1826:23](moz-extension://1a7428ef-1b52-488d-a85d-0a9dc5636bd3/runtime/pyscript.js)
[pyscript/main] config loaded:
{
"schema_version": 1,
"type": "app",
"runtimes": [
{
"src": "https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.js",
"name": "pyodide-0.21.3",
"lang": "python"
}
],
"packages": [],
"fetch": [],
"plugins": [],
"pyscript": {
"version": "2022.12.1",
"time": "2023-02-17T01:40:32.198Z"
}
} [pyscript.js:1826:23](moz-extension://1a7428ef-1b52-488d-a85d-0a9dc5636bd3/runtime/pyscript.js)
[py-splashscreen] add py-splashscreen [pyscript.js:1826:23](moz-extension://1a7428ef-1b52-488d-a85d-0a9dc5636bd3/runtime/pyscript.js)
[py-terminal] No <py-terminal> found, adding one [pyscript.js:1826:23](moz-extension://1a7428ef-1b52-488d-a85d-0a9dc5636bd3/runtime/pyscript.js)
[pyscript/main] Initializing runtime [pyscript.js:1826:23](moz-extension://1a7428ef-1b52-488d-a85d-0a9dc5636bd3/runtime/pyscript.js)
[pyscript/pyodide] Runtime config:
Object { name: "pyodide-0.21.3", lang: "python", src: "https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.js" }
[pyscript.js:1826:23](moz-extension://1a7428ef-1b52-488d-a85d-0a9dc5636bd3/runtime/pyscript.js)
[pyscript/main] Downloading pyodide-0.21.3... [pyscript.js:1826:23](moz-extension://1a7428ef-1b52-488d-a85d-0a9dc5636bd3/runtime/pyscript.js)
before [borderify.js:1:9](moz-extension://1a7428ef-1b52-488d-a85d-0a9dc5636bd3/borderify.js)
between [borderify.js:12:9](moz-extension://1a7428ef-1b52-488d-a85d-0a9dc5636bd3/borderify.js)
Source map error: Error: NetworkError when attempting to fetch resource.
Resource URL: moz-extension://1a7428ef-1b52-488d-a85d-0a9dc5636bd3/runtime/pyscript.js
Source Map URL: pyscript.js.map
[pyscript/main] Python startup... [pyscript.js:1826:23](moz-extension://1a7428ef-1b52-488d-a85d-0a9dc5636bd3/runtime/pyscript.js)
[pyscript/pyodide] Loading pyodide [pyscript.js:1826:23](moz-extension://1a7428ef-1b52-488d-a85d-0a9dc5636bd3/runtime/pyscript.js)
TypeError: window.loadPyodide is not a function
I had hoped that ordering pyodide before pyscript in my manifest.json would load it first, then pyscript would find that it was already loaded locally and not try to download it (which it seems to do). Does anyone see a way that this could work? TIA for any help and for a really interesting project!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Context:
I enjoyed and was able to build this example Chrome extension that uses pyscript. Too cool! I use Firefox, and I know a modest bit of python but nearly no JavaScript, so I was interested in making my first-ever Firefox extension with pyscript (starting with just a hello world).
I was hoping to do something similar to a mashup of the project above and the Mozilla extension quickstart, for which I'd be using pyscript directly in the javascript part of the extension, perhaps via
pyscript.runtime.interpreter.runPython
, instead of being loaded inindex.html
.Unfortunately I haven't been able to get it to work. I'm very new to JavaScript, but from what I can tell the issue is that pyscript can't find the local
runtime/pyodide
; I set this inpy-config
as done here, but JavaScript is going to be operating in the context of the webpage it is running on, so it looks for that as a local path from the webpage.My
manifest.json
:borderify.js
, (obviously not borderifying anything at this time):I had hoped that ordering
pyodide
beforepyscript
in my manifest.json would load it first, then pyscript would find that it was already loaded locally and not try to download it (which it seems to do). Does anyone see a way that this could work? TIA for any help and for a really interesting project!Beta Was this translation helpful? Give feedback.
All reactions