I’m trying to use a higher version of pyodide with pyscript by including the tag:
- autoclose_loader: false
- runtimes:
- src: "https://cdn.jsdelivr.net/pyodide/v0.21.2/full/pyodide.js"
name: pyodide-0.21.2
lang: python
However, the runtime never loads. I tried with the current stable version as well, and having the same issues.
- autoclose_loader: false
- runtimes:
- src: "https://cdn.jsdelivr.net/pyodide/v0.20.0/full/pyodide.js"
name: pyodide-0.20
lang: python
Any help or advice on this would be a great help.
1 Like
You cannot easily change the Pyodide version. PyScript loads Pyodide itself.
The PyScript “unstable” version includes Pyodide 0.21.2.
https://pyscript.net/unstable/pyscript.js
This article explains in more detail:
Announcing PyScript Versioning: What You Should Know
1 Like
@john.hanley This has actually changed: Using the py-config tag, we can now cause PyScript to load a specific version of pyodide.
@neha.educational I wonder if perhaps there’s a syntax error in your YAML? Do you see any errors in the developer console?
The following works for me when linking to what is currently “latest” (2022.06.1
at time of writing):
<py-config>
autoclose_loader: true
runtimes:
- src: "https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.js"
name: pyodide-0.21.3
lang: python
</py-config>
<py-script>
import pyodide_js
print(pyodide_js.version)
</py-script>
#prints 0.21.3 to the screen
Note that, as of PR #754’s merge last week, the current unstable versions (and future stable releases) will use JSON instead of YAML for py-config. The following works for me in the current unstable build (as of commit a1a16ab):
<py-config>
{
"runtimes": [{
"src": "https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.js",
"name": "pyodide-0.21.3",
"lang": "python"
}]
}
</py-config>
<py-script>
import pyodide_js
print(pyodide_js.version)
</py-script>
#Prints 0.21.3 to the developer console
2 Likes
Thanks for the article @john.hanley . Lots of useful information in there!
1 Like
Thanks @JeffGlass . I did not see any errors, it just wouldn’t stop loading. I compared my code to yours and updated the autoclose_loader value to true. This resolved the issue. Thanks so much for all the help here!
1 Like
@JeffGlass - I found breaking changes in Pyodide 0.21.2. That is why I did not recommend your method of using <py-config>
, which I feel should only be used at this time to load the same version of Pyodide that PyScript has been tested against.
One benefit of <py-config>
is to load pyodide from a different URL e.g. your website or cloud storage location or from localhost to speed up page loads.
1 Like
That’s a really good point John, and something I hadn’t considered.
Personally, I think using <py-config>
to load different versions of Pyodide to be a useful way of trying out those different versions and their new features/fixes, but that also means I take it on myself to recognize that this may break PyScript more fundamentally in the process. It’s very much a “at your own risk” situation, and I should have made that more explicit.
1 Like