This guide explains how to lock package versions in Streamlit applications deployed from a GIT repository in the Keboola platform.
Locking package versions is essential for:
Follow this tutorial to package a simple Python project, set up the required files and structure, build the package, and upload it to the Python Package Index. For information on installing dependencies, refer to the Streamlit documentation.
To ensure your Streamlit app runs reliably in Keboola, follow these steps to lock package versions:
Create and activate a Python virtual environment to isolate your app’s dependencies:
python3 -m venv venv
source venv/bin/activate # On Linux/Mac
venv\Scripts\activate # On Windows
Install the necessary packages for your Streamlit app:
pip install streamlit pandas numpy
Generate a requirements.txt
file to lock the versions of all installed packages:
pip freeze > requirements.txt
This file lists all installed packages along with their specific versions. It ensures consistent package versions across environments (development and production) and prevents dependency conflicts.
Note: After updating or installing a new dependency, remember to run pip freeze
again to update your requirements.txt
file.
Below is an example optimized for a typical Streamlit app running in Keboola:
streamlit==1.24.0
pandas==1.3.5
numpy==1.21.6
plotly==5.20.0
matplotlib==3.7.2
requests==2.31.0
protobuf==3.19.6
validators==0.20.1
pydeck==0.8.1b0
watchdog==3.0.0
Following these best practices will help you maintain a stable, efficient, and consistent environment for your Streamlit applications in Keboola.
requirements.txt
file.