I created a web app that generates a report which can be downloaded as PDF. The app was first deployed in 2024, and it worked as intended until recently. Now I’m getting an error. I provide the details below, hope you can help.
Link to the public app: https://droplets.streamlit.app/
Link to the app’s public GitHub repository: GitHub - pbrevis/analisis-gotas: Web app para análisis de gotas en papel hidrosensible · GitHub
Some highlights of the code:
packages.txt
wkhtmltopdf
requirements.txt
pdfkit
App’s Python code
import base64
from io import BytesIO
import pdfkit
config = pdfkit.configuration()
pdf_bytes = pdfkit.from_string(contenido_html, False, configuration=config, options=formato)
st.sidebar.download_button(label='Bajar PDF', data=pdf_bytes,
file_name="resultados.pdf", mime='application/octet-stream')
The error message:
Package wkhtmltopdf is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or is only available from another source
E: Package 'wkhtmltopdf' has no installation candidate
[19:32:04] ❗️ installer returned a non-zero exit code
[19:32:04] ❗️ Error during processing dependencies! Please fix the error and push an update, or try restarting the app.
How can I fix this? Thanks!
Hey, thanks for sharing all the details and welcome to the Streamlit community!
Your issue is caused by the fact that the wkhtmltopdf package is no longer available in the default Debian repositories used by Streamlit Community Cloud, so the install fails and your app can’t generate PDFs.
To fix this, you have a couple of options:
- Switch to an alternative PDF generation library (like WeasyPrint or ReportLab) that doesn’t require a system-level binary, since these are pure Python and installable via requirements.txt.
- If you must use wkhtmltopdf, you’ll need to find a way to install it from a supported source. However, as of now, the default apt repositories on Streamlit Cloud do not provide wkhtmltopdf, and adding custom repositories is not supported. This means you can’t reliably install wkhtmltopdf via packages.txt anymore on Streamlit Cloud (see discussion, see also).
Recommended solution:
Switch to a pure Python PDF library like WeasyPrint. Add weasyprint to your requirements.txt and update your code to use it for HTML-to-PDF conversion. This avoids the need for system binaries and is fully supported on Streamlit Cloud.
If you need help converting your code to use WeasyPrint, let us know and share a minimum reproducible example! Also, if anyone in the community has found a workaround for installing wkhtmltopdf on Streamlit Cloud recently, please jump in and share your insights.
Sources: