Request to Include "openpyxl" Module as Default Dependency for Streamlit Application

Summary

Dear Streamlit Development Team,

I’m encountering an issue in my Streamlit application due to the absence of the “openpyxl” module in the runtime environment. The “openpyxl” module is required for the functionality of downloading data to an Excel file using the pandas library.

Since I don’t have access to the terminal to perform manual installation, I would like to request that “openpyxl” be included as a default dependency in the environment where my Streamlit application is being run. This will ensure that users of the application can download data without errors.

Please consider including “openpyxl” in the Streamlit environment or dependencies so that I can continue to use this functionality in my application.

I appreciate your attention and assistance in advance.

Best regards,

Steps to reproduce

Code snippet:

    if st.button("Clique aqui para baixar a base de dados"):
        download_base_dados()
        # Gere um link para o arquivo Excel gerado
        with open("base_dados.xlsx", "rb") as file:
            b64 = base64.b64encode(file.read()).decode()
            href = f'<a href="data:application/octet-stream;base64,{b64}" download="base_dados.xlsx">Download da base de dados</a>'
        st.markdown(href, unsafe_allow_html=True)

Expected behavior:

When clicking the ‘Click here to download the database’ button, initiate the download of the database.

Actual behavior:

File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 541, in _run_script
    exec(code, module.__dict__)File "/app/streamlitpython/main.py", line 203, in <module>
    main()File "/app/streamlitpython/main.py", line 195, in main
    download_base_dados()File "/app/streamlitpython/main.py", line 52, in download_base_dados
    with pd.ExcelWriter('base_dados.xlsx') as writer:File "/home/appuser/venv/lib/python3.9/site-packages/pandas/io/excel/_openpyxl.py", line 57, in __init__
    from openpyxl.workbook import Workbook

Debug info

  • Streamlit version: (get it with $ streamlit version) 1.27.0
  • Python version: (get it with $ python --version) 3.11.5
  • Using Conda? PipEnv? PyEnv? Pex? No.
  • OS version: Windows
  • Browser version: Google Chrome 117.0.5938.134

Requirements file

Using Conda? PipEnv? PyEnv? Pex? No.

Links

Additional information

When running the code locally with the ‘openpyxl’ module installed, everything works perfectl

Oh ! i seem you didn’t add openpyxl in your projects requirement.txt
just add this

openpyxl==3.1.2 

hope this solves your issue !

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