[英]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 statement将data_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.