FileNotFoundError: [Errno 2] No such file or directory on streamlit cloud

Summary

Hello There! I have made an app. The app worked on localhost but on streamlit cloud it doesn’t work.
Please tell me why.

Steps to reproduce

Code snippet:

# Download and save each file
    for item in items:
        file_id = item["id"]
        file_name = item["name"]
        # ファイルの内容をバイト列として変数に格納
        file_content = service.files().get_media(fileId=file_id).execute()

        if file_content is not None:
            file_path = os.path.join('./temp', file_name)
            with open(file_path, "wb") as f:
                f.write(file_content)

error

FileNotFoundError: [Errno 2] No such file or directory: ‘./temp/営業企画通達no297_アウトドアスプレーならびにマスクスプレ-について取扱いのお願い.pdf’

The error is saying that there is no such file in that path
so your code is looking for pdf file in ./temp but there is no such file in cloud
either you add them manually or chech where the pdf files are being stored

1 Like

Thank you for your reply!
I think this code(with open(file_path, “wb”) as f:) make PDFfile of file_path.
But it wasn’t made. On localhost it was made it but on streamlit cloud wasn’t made it.

If you know why please tell me.
Thank you for your cooperation.

Umm well i doubt if you have create temp folder before executing it its better to create temp folder there and then try

or also once try with english characters just to see if its due to japanese characters[not most likely]

Hopefully they will work

like make a temp directory in your github

Thank you for your helping!
I have know that cause of the error.
It is content of PDFfile.
The content can’t embedding caused that error.

For your support I was encouraged.
Thank you so much.

2 Likes

So it worked?

If I don’t use PDFfile of can’t embedding it worked.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.