文件<frozen codecs>,第322行,解码UnicodeDecodeError:“utf-8”编解码器无法解码位置0中的字节0xff:无效的起始字节

问题描述 投票:0回答:1

编写一个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。请帮忙!

python command-line streamlit
1个回答
0
投票

我在使用 Streamlit 时遇到了同样的错误。 要解决此错误,您必须将 config.toml 的编码更改为 utf-8 为此,必须使用文件资源管理器 在资源管理器中搜索config.toml,用notpad打开配置文件并将编码更改为utf-8并保存 要更改,请单击另存为,以便可以进行更改。 希望能帮助到你。 谢谢你。

IMAGE of utf-8 changing

© www.soinside.com 2019 - 2024. All rights reserved.