简体   繁体   English

AttributeError: 'NoneType' object 没有带有 streamlit 的属性 'name'

[英]AttributeError: 'NoneType' object has no attribute 'name' with streamlit

I am trying to display a pipeline script on the UI with streamlit and facing this error AttributeError: 'NoneType' object has no attribute 'name'我正在尝试使用 streamlit 在 UI 上显示管道脚本并遇到此错误AttributeError: 'NoneType' object has no attribute 'name'

My code is as follow我的代码如下

data_file = st.file_uploader("Upload raw file", type=["docx"])

    with open(os.path.join("/home/lungsang/Desktop/levelpack-UI/content/A0/1 docx-raw", data_file.name),
              "wb") as f:
        f.write(data_file.getbuffer())

The error i am getting:我得到的错误: 用户界面上的错误

If you guys know how to avoid this small error showing on the UI, please do share here, it would help alot:)如果你们知道如何避免在 UI 上显示这个小错误,请在这里分享,这将有很大帮助:)

Put data_file in if statementdata_file放入if 语句中

data_file = st.file_uploader("Upload raw file", type=["docx"])

if data_file is not None: # Added missing if statement
    with open(os.path.join("/home/lungsang/Desktop/levelpack-UI/content/A0/1 docx-raw", data_file.name),
              "wb") as f:
        f.write(data_file.getbuffer())

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

相关问题 Streamlit AttributeError: 'NoneType' object 没有属性 'session_id' - Streamlit AttributeError: 'NoneType' object has no attribute 'session_id' AttributeError: &#39;NoneType&#39; 对象没有属性 &#39;name&#39;? - AttributeError: 'NoneType' object has no attribute 'name'? AttributeError:&#39;NoneType&#39;对象没有属性&#39;name - AttributeError: 'NoneType' object has no attribute 'name AttributeError:&#39;NoneType&#39;对象没有属性&#39;name&#39; - AttributeError: 'NoneType' object has no attribute 'name' Flask AttributeError: 'NoneType' object 没有属性 'name' - Flask AttributeError: 'NoneType' object has no attribute 'name' Tkinter: AttributeError: NoneType object 没有属性<attribute name></attribute> - Tkinter: AttributeError: NoneType object has no attribute <attribute name> AttributeError: &#39;NoneType&#39; 对象没有属性 - AttributeError: 'NoneType' object has no attribute AttributeError:“ NoneType”对象没有属性“ a” - AttributeError: 'NoneType' object has no attribute 'a' Tensorflow:AttributeError:&#39;NoneType&#39;对象没有属性&#39;original_name_scope&#39; - Tensorflow: AttributeError: 'NoneType' object has no attribute 'original_name_scope' Scrapyd错误-AttributeError:“ NoneType”对象没有属性“ module_name” - Scrapyd error - AttributeError: 'NoneType' object has no attribute 'module_name'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM