TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

PyScript: Run Python in your HTML

317 pointsby gripfxabout 3 years ago

21 comments

eatonphilabout 3 years ago
This uses Pyodide [0] under the hood [1], which is CPython compiled to WebAssembly. In all my tests of it, loading takes a long time ~5 seconds. Coldbrew [2], another distribution of CPython on Wasm, is another option with similar load times.<p>And Brython [3] is a completely different option without long load time: a Python interpreter implemented in JavaScript.<p>If load time is important, Brython is pretty nice. If feature completeness is important, Pyodide and Coldbrew are probably best.<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;pyscript&#x2F;pyscript&#x2F;blob&#x2F;main&#x2F;pyscriptjs&#x2F;src&#x2F;App.svelte#L15" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;pyscript&#x2F;pyscript&#x2F;blob&#x2F;main&#x2F;pyscriptjs&#x2F;sr...</a><p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;pyodide&#x2F;pyodide" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;pyodide&#x2F;pyodide</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;plasticityai&#x2F;coldbrew" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;plasticityai&#x2F;coldbrew</a><p>[3] <a href="https:&#x2F;&#x2F;github.com&#x2F;brython-dev&#x2F;brython" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;brython-dev&#x2F;brython</a>
评论 #31220766 未加载
评论 #31220528 未加载
评论 #31220857 未加载
评论 #31229563 未加载
评论 #31224012 未加载
closedabout 3 years ago
For some reason, I can&#x27;t see this linked anywhere on the site, but there is an examples page:<p><a href="https:&#x2F;&#x2F;pyscript.net&#x2F;examples&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pyscript.net&#x2F;examples&#x2F;</a><p>(This was presented today as a pycon keynote talk!)
评论 #31219493 未加载
评论 #31218738 未加载
评论 #31218540 未加载
评论 #31220576 未加载
BossingAroundabout 3 years ago
Based on the responses, I assume this is a silly question, but why? Why would I want to run Python in HTML?<p>Does Python have some libraries that JS is missing? (I could think of AI&#x2F;ML libs) The examples [1] seem so slow in my browser (Firefox on an Intel-based MBP) that they are borderline unusable for me (and some of them just straight out don&#x27;t load within 60 seconds, like the Bokeh, at which point I give up).<p>[1] <a href="https:&#x2F;&#x2F;pyscript.net&#x2F;examples" rel="nofollow">https:&#x2F;&#x2F;pyscript.net&#x2F;examples</a>
评论 #31226183 未加载
评论 #31223763 未加载
评论 #31234705 未加载
评论 #31226471 未加载
grejabout 3 years ago
This is awesome and has so much potential!<p>Regarding the size of the download, I know there is ongoing work in the Pyodide project to create a much smaller python runtime that will help tremendously. Also, the script will be cached once you download it once.<p>EDIT: Also, you don&#x27;t need NPM or anything locally to run these
评论 #31234574 未加载
asimjalisabout 3 years ago
The GitHub repo has a more concrete overview.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;pyscript&#x2F;pyscript" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;pyscript&#x2F;pyscript</a><p>Would be nice if there was a demo on the page that didn’t require installing NPM and other stuff on my machine.
评论 #31219911 未加载
stavrosabout 3 years ago
I really really like this, but 4 MB zipped is a bit of a hard sell :&#x2F; I&#x27;ve had a need to deploy small ad-hoc HTML tools at work, though, and my Python is much better than my JS, so maybe it&#x27;s worth it.
评论 #31218844 未加载
评论 #31219588 未加载
hotenabout 3 years ago
Super cool.<p>Any reason to use a custom element `py-script` vs a script tag with custom type?
VectorLockabout 3 years ago
I want this so bad with every fiber of my being.
stuntkiteabout 3 years ago
I&#x27;ve learned to accept my larger snake overlord. I know a lot of people work very hard on the anaconda project. It is a fork of what I consider to be actually pythonic. I am pretty sure there are a lot of big money actors working in the space to &quot;Embrace, Extinguish, Destroy&quot; what I know to be Python via the Anaconda project. This is really interesting stuff and is the first evidence I&#x27;ve seen other than money and some very specific political stuff that shows me they might do something worth something. Congrats! I will use this! I mourn what&#x27;s lost, but embrace the future.
patrick91about 3 years ago
Looks pretty cool! we recently release <a href="https:&#x2F;&#x2F;play.strawberry.rocks" rel="nofollow">https:&#x2F;&#x2F;play.strawberry.rocks</a> which also uses Pyodide, can&#x27;t wait to have more python stuff in the browsers!
als0about 3 years ago
I for one welcome our new WASM overlords
VWWHFSfQabout 3 years ago
Is this similar at all to the old pyjs&#x2F;pyjamas project? I had some fun playing with that but there was no way I would have ever actually made anything serious with it.
评论 #31218267 未加载
评论 #31218170 未加载
999900000999about 3 years ago
Thank you for posting this.<p>Of course it would be better if Chrome shipped with Python support, but this is a good effort. Does Wasm generally support other languages ?
评论 #31220593 未加载
nathanganserabout 3 years ago
This is super exciting! Lots of potential to create easy python courses online :)
ericdabout 3 years ago
Pyodide is really cool, we got a Python library we were working on working in JS in the browser with it, including Pandas iirc, without too much trouble (though getting http requests working required a little hackery).
_pdp_about 3 years ago
Python is the worst language to script anything inside a markup language that does not need to be structured like Python (HTML). So yeah, a good experiment, but unfortunately it is doomed to fail.
评论 #31230028 未加载
alanhabout 3 years ago
Is there a playground&#x2F;fiddle?
cutlerabout 3 years ago
Why not &lt;py&gt;&lt;&#x2F;py&gt; instead of &lt;py-script&gt;&lt;&#x2F;py-script&gt; ?
评论 #31221273 未加载
ak391about 3 years ago
cool project, check out <a href="https:&#x2F;&#x2F;gradio.app&#x2F;" rel="nofollow">https:&#x2F;&#x2F;gradio.app&#x2F;</a> as well, makes a web demo with just python
farminabout 3 years ago
I suppose this is how I can get python into flutter app too?
评论 #31219465 未加载
101008about 3 years ago
Don&#x27;t hate me for saying this, but I can imagine combining this with Electron and develop desktop apps with Python.
评论 #31220749 未加载
评论 #31233066 未加载
评论 #31220444 未加载