TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

PyScript: An open source platform for Python in the browser

274 点作者 xiaodai9 个月前

28 条评论

apwheele9 个月前
For folks interested in seeing a usecase, I have a panel dashboard of Dallas crime statistics at:<p><a href="https:&#x2F;&#x2F;crimede-coder.com&#x2F;graphs&#x2F;Dallas_Dashboard" rel="nofollow">https:&#x2F;&#x2F;crimede-coder.com&#x2F;graphs&#x2F;Dallas_Dashboard</a><p>Startup takes around a minute (which includes installing various python libraries + loading an external 5mb dataset). But once up and running it is quite responsive. (And works fine on my iphone.)<p>Many businesses I work with use Tableau free versions, and just manually update the data (since the free doesn&#x27;t allow direct connections to a datastore). This is a free alternative (I use github actions to build a zipped up csv file that is pulled into the environment).
评论 #41266524 未加载
评论 #41306842 未加载
评论 #41266967 未加载
评论 #41272132 未加载
评论 #41271485 未加载
评论 #41265272 未加载
评论 #41271762 未加载
评论 #41270992 未加载
评论 #41272208 未加载
mg9 个月前
The homepage left me confused, and also after reading the documentation, I&#x27;m not sure what this is.<p>I tinkered a bit to try it myself.<p>Turns out you can throw this into your website and it will display &quot;Hello World&quot;:<p><pre><code> &lt;script type=&quot;module&quot; src=&quot;https:&#x2F;&#x2F;pyscript.net&#x2F;releases&#x2F;2024.8.2&#x2F;core.js&quot;&gt;&lt;&#x2F;script&gt; &lt;script type=&quot;py&quot;&gt; import js js.document.querySelector(&quot;body&quot;).innerText = &quot;Hello World&quot; &lt;&#x2F;script&gt; </code></pre> So it seems to be a script that looks for scripts of type &quot;py&quot; and transpiles them from Python to JavaScript via Pyodide?<p>On the other hand, the demo on the homepage is a repl. And the title says &quot;platform&quot;. So I&#x27;m still confused.
评论 #41264455 未加载
评论 #41265432 未加载
评论 #41264953 未加载
评论 #41265415 未加载
Loeffelmann9 个月前
How is this different from pyodide[0]?<p>[0]: <a href="https:&#x2F;&#x2F;pyodide.org&#x2F;en&#x2F;stable&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pyodide.org&#x2F;en&#x2F;stable&#x2F;</a>
评论 #41264157 未加载
评论 #41264147 未加载
评论 #41269241 未加载
评论 #41264916 未加载
pitah19 个月前
I recently went down the rabbit hole of using PyScript for running a Python CLI app in the browser.<p>It felt hacky the whole time, especially when dependencies were involved. I had to create wrapper classes to work around Pydantic 2.x not being available to use. I tried to put all logic into the Python files but found some things missing that I had to put in JavaScript.<p>I think it could be good in use cases where you want some simple UI with custom UI logic on top of your Python code but maybe Streamlit or Gradio could be more suitable.<p>GitHub repo: <a href="https:&#x2F;&#x2F;github.com&#x2F;data-catering&#x2F;data-contract-playground">https:&#x2F;&#x2F;github.com&#x2F;data-catering&#x2F;data-contract-playground</a><p>Website: <a href="https:&#x2F;&#x2F;data-catering.github.io&#x2F;data-contract-playground&#x2F;" rel="nofollow">https:&#x2F;&#x2F;data-catering.github.io&#x2F;data-contract-playground&#x2F;</a>
评论 #41271574 未加载
v3ss0n9 个月前
I can&#x27;t find any real world use case there. If you want to run ML Models you can build them to Onnx <a href="https:&#x2F;&#x2F;onnxruntime.ai&#x2F;docs&#x2F;tutorials&#x2F;web&#x2F;" rel="nofollow">https:&#x2F;&#x2F;onnxruntime.ai&#x2F;docs&#x2F;tutorials&#x2F;web&#x2F;</a> . Will this efficient to build browser based app in place of JS&#x2F;TS ?
评论 #41265385 未加载
评论 #41268382 未加载
deknos9 个月前
What i would like, if i could write scripts in firefox, which act the browser, like doing the evaluation at any stage i like. At GET the page, after ALL GETs. After javascript evaluation or before.<p>Is there something which can do this? and with full power of python also accessible to the host?
评论 #41271557 未加载
zygentoma9 个月前
Isn&#x27;t this the same concept as brython? (BRowser pYTHON)<p><a href="https:&#x2F;&#x2F;brython.info&#x2F;" rel="nofollow">https:&#x2F;&#x2F;brython.info&#x2F;</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;brython-dev&#x2F;brython">https:&#x2F;&#x2F;github.com&#x2F;brython-dev&#x2F;brython</a>
评论 #41265059 未加载
bouncing9 个月前
If I may toot my own horn, I wrote a somewhat more opinionated, reactive, frontend framework using PyScript. It&#x27;s inspired by Vue.js, a bit: <a href="https:&#x2F;&#x2F;puepy.dev" rel="nofollow">https:&#x2F;&#x2F;puepy.dev</a>
amanzi9 个月前
I used this to create a Markdown renderer a while back. You can see the very simple source code here: <a href="https:&#x2F;&#x2F;pyscript.com&#x2F;@stuartmaxwell&#x2F;markdown-previewer-v2&#x2F;latest" rel="nofollow">https:&#x2F;&#x2F;pyscript.com&#x2F;@stuartmaxwell&#x2F;markdown-previewer-v2&#x2F;la...</a><p>The app won&#x27;t run well on mobile but should be fine on desktop.<p>I used this code in a blog application I was writing in Django.
raybb9 个月前
The big limitation that&#x27;s very annoying with any WASM setup is that at the end of the day you still can&#x27;t call many APIs or scrape sites because of CORS. Ofcourse, CORS is important to avoid XSS and the like but I wish there was a way to deal with this other than setting up a proxy to strip CORS, which then leaves you with a non residential IP that&#x27;s more likely to get blocked.
评论 #41278336 未加载
bArray9 个月前
I&#x27;ve been looking for something like this, but I&#x27;m still unsure it quite hits the spot. I think that this would be very interesting if it allows a person to run a blog like a Jupyter notebook.<p>I have a lightweight hack [1] that runs Python in markdown documents and can output basic images&#x2F;graphs - which is embedded into static pages. The point was being able to write an article that somebody else could see the code behind it and test themselves, e.g. [2]. One of the browsers I test in is Netsurf with JS disabled. Unfortunately it doesn&#x27;t look great in Lynx.<p>[1] <a href="https:&#x2F;&#x2F;gitlab.com&#x2F;danbarry16&#x2F;pandoc-highlight-filter" rel="nofollow">https:&#x2F;&#x2F;gitlab.com&#x2F;danbarry16&#x2F;pandoc-highlight-filter</a><p>[2] <a href="https:&#x2F;&#x2F;coffeespace.org.uk&#x2F;projects&#x2F;langtons-ant-universe.html" rel="nofollow">https:&#x2F;&#x2F;coffeespace.org.uk&#x2F;projects&#x2F;langtons-ant-universe.ht...</a>
评论 #41265177 未加载
jedberg9 个月前
First thing I tried was a small lambda function and it worked! Then I tried some Fibonacci with tail recursion and surprisingly that worked too. I&#x27;m impressed, because often when people reimplement the Python interpreter they get those wrong.
评论 #41268598 未加载
评论 #41268686 未加载
bdcravens9 个月前
Reminds me of my first &quot;tech&quot; job (computer store&#x2F;ISP&#x2F;web dev shop, circa 1998) where the owner wrote some VBScript for the browser and wondered why it didn&#x27;t work in Netscape.
a10sshg9 个月前
This is from Anaconda and built on Pyodide:<p><i>PyScript is currently built on Pyodide, which is a “port of CPython to WebAssembly&#x2F;Emscripten.” PyScript supports writing and running Python code in a browser.</i><p>Like <i>conda</i> I find the whole thing very confusing and slow, but I suppose it will be marketed to academics as &quot;the thing to do web development with&quot;. It will also be soft-abandoned.<p>Just use Javascript, PHP or Scala like lichess.org, which is a professional website.
nickpsecurity9 个月前
For those exploring, here was one of the best “Python in the browser” projects I found:<p><a href="https:&#x2F;&#x2F;brython.info&#x2F;" rel="nofollow">https:&#x2F;&#x2F;brython.info&#x2F;</a>
grej9 个月前
Also check out pyscript.com, to create and host PyScript apps.
laffra9 个月前
Also, check out PySheets (<a href="https:&#x2F;&#x2F;pysheets.app" rel="nofollow">https:&#x2F;&#x2F;pysheets.app</a>), which leverages PyScript to run Python logic in a spreadsheet UI, which is written entirely in Python. The PySheets UI uses LTK (<a href="https:&#x2F;&#x2F;github.com&#x2F;pyscript&#x2F;ltk">https:&#x2F;&#x2F;github.com&#x2F;pyscript&#x2F;ltk</a>), a fully client-side UI rendering library for PyScript.
maartenbreddels9 个月前
Also check out <a href="https:&#x2F;&#x2F;py.cafe&#x2F;" rel="nofollow">https:&#x2F;&#x2F;py.cafe&#x2F;</a> (I work on this project)<p>It supports streamlit, dash, virzo and solara. Frameworks like shiny, gradio and panel are planned (maybe even fasthtml).<p>It&#x27;s also really nice to integrate this into your documentation: <a href="https:&#x2F;&#x2F;mkdocs.py.cafe&#x2F;" rel="nofollow">https:&#x2F;&#x2F;mkdocs.py.cafe&#x2F;</a>
agumonkey9 个月前
What other language would people choose in a browser? Lua ?
评论 #41266324 未加载
n8henrie9 个月前
I tried to write a POC Firefox extension in pyscript but ended up having to fall back to pyodide. Was a fun experiment anyway.<p><a href="https:&#x2F;&#x2F;n8henrie.com&#x2F;2023&#x2F;06&#x2F;write-a-firefox-extension-in-python&#x2F;" rel="nofollow">https:&#x2F;&#x2F;n8henrie.com&#x2F;2023&#x2F;06&#x2F;write-a-firefox-extension-in-py...</a>
评论 #41271600 未加载
bityard9 个月前
Why does it require signing in just to try it out? Someone else below mentioned that it&#x27;s just adding a &lt;script&gt; tag to your HTML.
Falimonda9 个月前
Does something built off this or Pyodide exist that&#x27;s effectively a replacement to using React?
jerpint9 个月前
I wonder if this could be combined with fastHTML to have a full python html rendered client side
评论 #41273215 未加载
评论 #41265775 未加载
IshKebab9 个月前
The examples were about as slow as I imagined they would be. 20 seconds to draw a simple graph.
评论 #41265576 未加载
bilsbie9 个月前
How’s it work? Webassembly? Webile?
SillyUsername9 个月前
Someone just invented a whole new level of hell for devs who maintain code.<p>First it was untrained consultants and VB or Delphi (Pascal)<p>Then came the JS monkeys mixing up plain JS with jQuery and SQL injections.<p>Now it&#x27;s time for data scientists and pi&#x2F;sketch users to feel the pain of an uncharted domain...
评论 #41265866 未加载
评论 #41266702 未加载
评论 #41267748 未加载
评论 #41271526 未加载
评论 #41267364 未加载
评论 #41271711 未加载
bschwindHN9 个月前
Our phones are getting faster every year, we must find a way to slow things down even more.
评论 #41269302 未加载
评论 #41268019 未加载
评论 #41265481 未加载
评论 #41271712 未加载
apples2apples9 个月前
Careful Anaconda will change the license on you and then sue...
评论 #41270423 未加载