编写一个Python文件app.py并在环境中使用streamlit运行它,当我使用以下命令运行app.py时,我不断收到此错误:
streamlit run app.py
app.py代码:
from PIL import Image
import requests
from os import path
import streamlit as st
from streamlit_lottie import st_lottie
st.set_page_config(
page_title="Project Recommender System",
page_icon=":tada:",
layout="wide",
)
# --function to access json data from animation file --
def load_lottieurl(url):
r=requests.get(url)
if r.status_code!=200:
return None
return r.json()
lottie_coding="https://lottie.host/?file=27f9afaf-6b4d-4b82-9ddd-0090383cc539/uiGM12Tq9s.json"
img_contact_form = Image.open("images/project-contact-form.png")
img_lottie_animation=Image.open("images/stock-price-prediction-web-app.png")
with st.container():
st.subheader("AcademiaLink's Project Recommender System")
st.title("A recommender system for projects of your choice")
# -- Opens Home page --
# st.write("[Explore AcademiaLink >]()")
with right_column:
st_lottie(lottie_coding, height=300, key="coding")
with st.container():
st.header("Project Recommendations")
st.write("---")
image_col, text_col=st.columns((1,2))
with image_col:
st.image(img_lottie_animation)
with text_col:
st.subheader("Sales Forecasting using ARIMA")
st.write(
"""This is a machine learning project which performs exploratory data analysis on sales forecasting using ARIMA. The dataset used in the project is acquired from Kaggle and since the data proves to be seasonal, we use SARIMAX class model to derive apt and accurate predictions for the next 36 months.
"""
)
st.markdown("[Explore the project](https://github.com/vindhya1103/Sales-Forecasting-using-ARIMA)")
with st.container():
image_col, text_col = st.columns((1,2))
with image_col:
st.image(img_contact_form)
with text_col:
st.subheader("")
st.write()
st.markdown("[Explore the project]()")
命令streamlit run app.py后在命令行中输出:
C:\Users\Vindhya Sree\toolswebapp>streamlit run app.py
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\Vindhya Sree\AppData\Roaming\Python\Python311\Scripts\streamlit.exe\__main__.py", line 7, in <module>
File "C:\Users\Vindhya Sree\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Vindhya Sree\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "C:\Users\Vindhya Sree\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Vindhya Sree\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Vindhya Sree\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Vindhya Sree\AppData\Roaming\Python\Python311\site-packages\streamlit\web\cli.py", line 201, in main_run
bootstrap.load_config_options(flag_options=kwargs)
File "C:\Users\Vindhya Sree\AppData\Roaming\Python\Python311\site-packages\streamlit\web\bootstrap.py", line 367, in load_config_options
config.get_config_options(force_reparse=True, options_from_flags=options_from_flags)
File "C:\Users\Vindhya Sree\AppData\Roaming\Python\Python311\site-packages\streamlit\config.py", line 1229, in get_config_options
file_contents = input.read()
^^^^^^^^^^^^
File "<frozen codecs>", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
我还尝试以管理员身份运行该命令,并对编码和一些页面图标进行了一些更改。更改了所有utf-8编码并使用pip安装了tensorflow。我期望输出能够提供本地主机 Web URL。请帮忙!