From fd24050c307b77e0626c41262ab4fd63aa69e92c Mon Sep 17 00:00:00 2001 From: Debbie Matthews Date: Sun, 22 Dec 2024 20:22:18 -0800 Subject: [PATCH] Warn about Python version with app dependencies (#1209) * Warn about Python version with app dependencies * Add warning to deployment concepts --- .../community-cloud/deploy-your-app/app-dependencies.md | 8 +++++++- content/deploy/concepts/dependencies.md | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/content/deploy/community-cloud/deploy-your-app/app-dependencies.md b/content/deploy/community-cloud/deploy-your-app/app-dependencies.md index a869aba78..a994f40d8 100644 --- a/content/deploy/community-cloud/deploy-your-app/app-dependencies.md +++ b/content/deploy/community-cloud/deploy-your-app/app-dependencies.md @@ -23,7 +23,13 @@ directory as your app's entrypoint file. With each `import` statement in your script, you are bringing in a Python dependency. You need to tell Community Cloud how to install those dependencies through a Python package manager. We recommend using a `requirements.txt` file, which is based on `pip`. -You should _not_ include built-in Python libraries like `math` or `random` in your `requirements.txt` file. These are a part of Python and aren't installed separately. Also, Community Cloud has `streamlit` installed by default. You don't strictly need to include `streamlit` unless you want to pin or restrict the version. If you deploy an app without a `requirements.txt` file, your app will run in an environment with just `streamlit` (and its dependencies) installed. +You should _not_ include built-in Python libraries like `math`, `random`, or `distutils` in your `requirements.txt` file. These are a part of Python and aren't installed separately. Also, Community Cloud has `streamlit` installed by default. You don't strictly need to include `streamlit` unless you want to pin or restrict the version. If you deploy an app without a `requirements.txt` file, your app will run in an environment with just `streamlit` (and its dependencies) installed. + + + +The version of Python you use is important! Built-in libraries change between versions of Python and other libraries may have specific version requirements, too. Whenever Streamlit supports a new version of Python, Community Cloud quickly follows to default to that new version of Python. Always develop your app in the same version of Python you will use to deploy it. For more information about setting the version of Python when you deploy your app, see [Optional: Configure secrets and Python version](/deploy/streamlit-community-cloud/deploy-your-app/deploy#optional-configure-secrets-and-python-version). + + If you have a script like the following, no extra dependencies would be needed since `pandas` and `numpy` are installed as direct dependencies of `streamlit`. Similarly, `math` and `random` are built into Python. diff --git a/content/deploy/concepts/dependencies.md b/content/deploy/concepts/dependencies.md index aca2e1f1c..94cbb5919 100644 --- a/content/deploy/concepts/dependencies.md +++ b/content/deploy/concepts/dependencies.md @@ -22,7 +22,13 @@ If you are using Streamlit Community Cloud, you'll have the latest version of St ### `pip` and `requirements.txt` -Since `pip` comes by default with Python, the most common way to configure your Python environment is with a `requirements.txt` file. Each line of a `requirements.txt` file is a package to `pip install`. You should _not_ include built-in Python libraries like `math` or `random` in your `requirements.txt` file. These are a part of Python and aren't installed separately. +Since `pip` comes by default with Python, the most common way to configure your Python environment is with a `requirements.txt` file. Each line of a `requirements.txt` file is a package to `pip install`. You should _not_ include built-in Python libraries like `math`, `random`, or `distutils` in your `requirements.txt` file. These are a part of Python and aren't installed separately. + + + +Since dependencies may rely on a specific version of Python, always be aware of the Python version used in your development environment, and select the same version for your deployment environment. + + If you have a script like the following, you would only need to install Streamlit. No extra dependencies would be needed since `pandas` and `numpy` are installed as direct dependencies of `streamlit`. Similarly, `math` and `random` are built into Python.