[Python] Unable to load pickle file in streamlit

Discussão em 'Python' iniciado por Stack, Março 12, 2025.

  1. Stack

    Stack Membro Participativo

    I have some code to deploy model in streamlit. I just upload all file to github and share it in streamlit app. Here is some code

    if str(course) == 'Multi-layer Perceptron':
    file = open("MLP.pkl",'rb')
    if str(course) == 'Logistic classifier':
    file = open("log_classifier.pkl",'rb')
    if str(course) == 'K-neighbour':
    file = open("Kneighbor_classifier.pkl",'rb')
    f str(course) == 'Naivebayes':
    file = open("naivebayes_classifier.pkl",'rb')

    model = pickle.load(f)


    It runs perfect in local. But in streamlit it has some bug

    ModuleNotFoundError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs.
    Traceback:
    File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/script_runner.py", line 354, in _run_script
    exec(code, module.__dict__)
    File "/app/nm-khdl/streamlit_app.py", line 45, in <module>
    model = pickle.load(file)


    It's the first time that I work on streamlit. So, thank you for reading! Have a nice day!

    Continue reading...

Compartilhe esta Página