liveBook · Manning

Chapter 2: Getting started with Streamlit

What you will learn in chapter 2 of Build Python Web Apps with Streamlit

This chapter introduces the path from preparing a Streamlit development environment through learning the development workflow to building a first password-checker app.

After this chapter you will be able to

Section by section

Introduction

This chapter introduces the path from preparing a Streamlit development environment through learning the development workflow to building a first password-checker app.

Key terms: development environment, Streamlit development workflow, password checker, version control, Git, code editing tools, virtual environments, GitHub repo, streamlit-in-action, chapter_02

2.1 Getting Streamlit up and running

This section identifies the Python and pip prerequisites and the pip command needed to install Streamlit.

Key terms: Python, Python 3.9, Python 3.11+, pip, pip install streamlit, Streamlit, appendix, installation guide

2.2 Setting up your development environment

This section introduces the development-environment choices that affect Streamlit development productivity and previews version control, code editors, and virtual environments.

Key terms: development environment, productivity, version control, editing tool, virtual environments, experienced Python developer, running Streamlit for the first time

2.2.1 Version control with Git

This subsection explains Git as version control for tracking, revisiting, experimenting with, and documenting code changes during development.

Key terms: version control, Git, versions of your code, document changes, thought process, development workflow

2.2.2 Code editors

This section explains why a dedicated code editor or IDE improves Python and Streamlit development, compares PyCharm with VS Code, and emphasizes that any editor plus a terminal is sufficient.

Key terms: code editor, Integrated Development Environment (IDE), syntax highlighting, debugging, code navigation, PyCharm, JetBrains, code completion, error detection, quick-fix suggestions

2.2.3 Virtual environments

This section explains how per-project Python virtual environments isolate dependencies to prevent library-version conflicts between projects.

Key terms: virtual environment, isolated instance of Python, libraries, dependencies, versions, dependency management, bugs, conflicts, venv, pipenv

2.3 Running Streamlit for the first time

This section runs Streamlit’s built-in Hello app so readers can see example capabilities and inspect their concise source code.

Key terms: Hello app, streamlit hello, terminal, animation, graph plotting, maps, tables, pandas dataframes, sidebar, Show Code

2.4 The Streamlit development workflow

This section presents the iterative Streamlit workflow for writing, running, testing, revising, and rerunning an app.

Key terms: Streamlit development workflow, Python file, code editor, terminal, browser, streamlit run <filename>, .py extension, browser window, Always Rerun, Rerun

2.5 Building your first app

This introduction previews the first-app walkthrough and encourages active experimentation while following it.

Key terms: concept, logic flow, complete app code, tinkering, experimenting, active role, initiative

2.5.1 A password checker

Introduces a password-checker app in which a user enters a password and receives pass/fail feedback for each password rule.

Key terms: password checker, password rules, pass, fail

2.5.2 Logic flow

This section traces how the password checker turns a user-entered password into rule results and color-coded feedback on screen.

Key terms: text input box, button, rules, dictionary, PASSED, FAILED, results, green, red, condition

2.5.3 Going through the code

This section walks through the password checker code, connecting its Python validation logic to the Streamlit elements that collect input and display rule-by-rule feedback.

Key terms: dictionary, keys, values, lambda, anonymous inline functions, pw, get_password_properties, dictionary comprehension, conditions, results

2.5.4 Running the app

This section shows how to launch the Password Checker app locally, access it through Streamlit’s URLs, and troubleshoot browser-launch problems.

Key terms: streamlit run, terminal, Password Checker, Streamlit server, Local URL, Network URL, localhost, port 8501, localhost:8501, browser

2.5.5 Making changes to the app

This section shows how to modify the Password Checker app and have Streamlit rerun it to display saved code changes.

Key terms: conditions dictionary, numeral test, Check Password!, source file, Rerun, Always Rerun, Run on Save, Settings

2.5.6 Killing and restarting the server

This section explains how to stop a running Streamlit server and restart it so browser app instances can reconnect.

Key terms: Streamlit server, terminal window, Ctrl-C, frontend app, CONNECTING, connection error, disabled button, streamlit run <filename>, restarts your server, frontend

2.6 Summary

This summary recaps the Python requirement, essential development tools, and the command-and-rerun workflow for running Streamlit apps.

Where this is used later

Concepts explained in this chapter

← Chapter 1: Introduction to Streamlit Chapter 3: Taking an app from concept to code →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.