FileNotFoundError: [Errno 2] No such file or directory: 'uploaded_file'

I am using streamlit in my local ubuntu and it gives an error
When I try to confirm the uploaded image
FileNotFoundError: [Errno 2] No such file or directory: ‘uploaded_file’

Traceback:

File "/home/stark/anaconda3/envs/mark/lib/python3.6/site-packages/streamlit/script_runner.py", line 332, in _run_script
    exec(code, module.__dict__)File "/home/stark/streamlit/streamlit.py", line 91, in <module>
    image = Image.open("uploaded_file")File "/home/stark/anaconda3/envs/mark/lib/python3.6/site-packages/PIL/Image.py", line 2891, in open
    fp = builtins.open(filename, "rb")

That snippet of code is in

st.subheader("checking subheader")
uploaded_file = st.file_uploader("CHoose an image___",type="jpg")
button = st.button("Confirm")

and

if button and uploaded_file is not None:
    image = Image.open("uploaded_file")
    st.image(image,caption="Uploaded Image",use_column_width = True)
    st.write("")
    st.write("Detecting..........")

You don’t need the quotes in this scenario. Just use:

image = Image.open(uploaded_file)

1 Like

Oh, my fault. Thanks much