英文:
How to run the streamlit on python (jupyter)
问题
我刚开始使用Streamlit,尝试在Jupyter上运行时,收到警告要求在浏览器中运行streamlit命令。我预期会得到一个URL地址,但实际上得到了不同的选项。如果我运行"streamlit run <filename.py>",什么都不会发生。有人可以帮助我理解我做错了什么吗?
英文:
I am pretty new using streamlit. I am trying to run it on jupyter and I get the warning telling me to run the streamlit command on the browser. I was expecting an url adress, however I got a different option. If i run streamlit run <filename.py>, nothing happens. Can anyone help me to understand what I am doing wrong?
答案1
得分: 2
以下是翻译好的内容:
根据您的标题提示,Python 和 Jupyter 是完全不同的东西。使用 Streamlit 最简单的方法就像粉色文字中所说的那样,在您安装 Streamlit 的系统命令行上运行它。
Jupyter 是一种具有自己的仪表盘功能的集成开发环境,Voila 是其中的一个模块。需要注意的是,最近还出现了 Solara,可以参考 "Web Apps in Python with Solara — A Streamlit Killer?" 了解更多信息,它基于 ipywidgets 进行构建。
Streamlit 和 Jupyter 可以一起使用,但不像您试图简单地尝试的那样容易。您可以参考这里,使用代理来使它们一起工作,但基本上 Streamlit 应用程序是一个独立的 URL 和软件。
或者查看这里。注意底部与您的标题非常相关,它声明:
"最近,我想在工作中创建一个 Streamlit 应用程序,但发现它与我在 Jupyter 中首选的工作流程不太匹配 - 因此创建了这个库来解决这个问题"
该工作使用一个技巧来不实际运行 Streamlit,根据公告帖子,"如果从 Jupyter 笔记本中运行脚本,那么它将包装现有的 Streamlit 方法,以将它们替换为 ipywidgets 的替代方法"。
英文:
As your title hints at, Python and Jupyter are vastly different things. The easiest way is to use streamlit is like the text in pink says, run it on the command like of system where you've installed Streamlit.
Jupyter is an IDE with its own dashboarding ability, Voila. Note that more recently, there is Solara, see Web Apps in Python with Solara — A Streamlit Killer?, that builds on ipywidgets, see here and here for more about that and how it makes things easier.
Streamlit and Jupyter can be used together but not as easily as you naively are attempting. You'll see here you can use a proxy to get it to working alongside, but basically the streamlit app is a separate URL and software.
Or see here. Note at the bottom, very pertinent to your title, it states:
>"I recently wanted to create a streamlit app at work, and found that it did not quite fit in with my preferred workflow with Jupyter - so this library was created to solve that problem"
That effort uses a trick to not actually run streamlit though, according to the announcement post, "if the script is run from a jupyter notebook, then it wraps existing streamlit methods to replace them with ipywidgets alternatives".
答案2
得分: 0
我终于明白我做错了什么。我试图在jupyter上按建议运行,如"streamlit run C:\User.....(以及警告的其余部分)"。但现在我明白,Anaconda不会以那种方式从jupyter上运行那个建议。我需要创建一个Python脚本(而不是Jupyter笔记本),然后使用Anaconda终端导航到该目录,并使用应用程序的名称运行Streamlit。
以下链接详细解释了每一步,附有示例:https://stackoverflow.com/a/76567170/8508004
英文:
I finally understood what I was doing wrong. I was trying to run the recommended on jupyter as "streamlit run C:\User.....(and the rest of the warning)". But now I understand that Anaconda won't run that recommendation from jupyter on that way. I needed to create a python script (not a jupyter notebook) and with Anaconda terminal navigate to that directory and run the streamlit with the name of the app.
The following link explains everything step by step with examples https://stackoverflow.com/a/76567170/8508004
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论