简体   繁体   English

为什么 Streamlit 找不到我的 python 文件?

[英]Why does Streamlit not find my python file?

I have Streamlit working in terminal ie the following runs in terminal:我有 Streamlit 在终端中工作,即在终端中运行以下命令:

$ streamlit hello

I am trying to create an app with the online tutorial but encounter an error - see below我正在尝试使用在线教程创建应用程序但遇到错误 - 见下文

https://docs.streamlit.io/en/latest/tutorial/create_a_data_explorer_app.html#let-s-put-it-all-together

I have saved the following in as uber_pickups.py我已将以下内容保存为 uber_pickups.py

import streamlit as st
import pandas as pd
import numpy as np

st.title('Uber pickups in NYC')

(base) lf-mac-0250:~ alastairhayes$ streamlit hello

  You can now view your Streamlit app in your browser.

  Local URL: http://localhost:8501
  Network URL: http://172.20.10.2:8501

^C Stopping... ^C停止...

(base) lf-mac-0250:~ alastairhayes$ streamlit run uber_pickups.py
Usage: streamlit run [OPTIONS] TARGET [ARGS]...

Error: Invalid value: File does not exist: uber_pickups.py

Where am I going wrong?我哪里错了? I have python 3.7.6 Many thanks!我有 python 3.7.6 非常感谢!

If you're using Windows OS, you may try the steps below:如果您使用的是 Windows 操作系统,您可以尝试以下步骤:

  1. First, you need to download Anaconda: https://www.anaconda.com/首先需要下载Anaconda: https://www.anaconda.com/

  2. Open the Anaconda PowerShell Prompt and type the following:打开 Anaconda PowerShell 提示并键入以下内容:

    conda list

    pip uninstall streamlit

  3. Then, create a new environment, and test out the following:然后,创建一个新环境,并测试以下内容:

    pip install streamlit

    streamlit hello

  4. Finally, you can test out streamlit on your code, replace your_app with the actual name of your file.最后,您可以在代码上测试 streamlit,将 your_app 替换为文件的实际名称。 Make sure you are in the same directory as your source code file.确保您与源代码文件位于同一目录中。

    streamlit run your_app.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM