Ovi Burcea
Ovi Burcea

Reputation: 1

"tarfile.ReadError: file could not be opened successfully" when loading a model in Streamlit app

I have the following line of code:

model = pickle.load(open('saved_models/model.pkl', 'rb'))
ReadError: file could not be opened successfully

Traceback:

File "C:\Users\ovist\AppData\Local\Programs\Python\Python39\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 556, in _run_script
    exec(code, module.__dict__)File "F:\Licenta\pages\models_page.py", line 44, in <module>
    model = pickle.load(open('saved_models/model.pkl', 'rb'))File "C:\Users\ovist\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\saving\pickle_utils.py", line 39, in deserialize_model_from_bytecode
    with tarfile.open(fileobj=b, mode="r") as archive:File "C:\Users\ovist\AppData\Local\Programs\Python\Python39\lib\tarfile.py", line 1625, in open
    raise ReadError("file could not be opened successfully")

The command works fine in a local python script instead of streamlit app.

Note: I am using Python 3.9.12

Upvotes: 0

Views: 290

Answers (0)

Related Questions