A VS Code extension that allows you to run Streamlit apps directly from the file explorer and view them in an integrated webview panel.
- Right-click integration: Right-click on any
.pyfile in the VS Code explorer - Context menu: Select "Preview Streamlit App" from the context menu
- Integrated webview: View the Streamlit app in a VS Code webview panel beside your editor
- Virtual environment support: Automatically detects and uses your active Python virtual environment
- Auto cleanup: Streamlit process is automatically terminated when the webview is closed
- VS Code: Version 1.74.0 or higher
- Python: Python 3.6+ with Streamlit installed
- Streamlit: Install with
pip install streamlit
- Clone or download this repository
- Open VS Code
- Go to Extensions (Ctrl+Shift+X)
- Click "..." menu and select "Install from VSIX..." or load the extension folder
- Open the extension folder in VS Code
- Press F5 to launch Extension Development Host
- Test the extension in the new VS Code window
- Right-click on any Python file (
.py) in the VS Code explorer - Select "Preview Streamlit App" from the context menu
- Wait for Streamlit to start (a few seconds)
- View your Streamlit app in the webview panel that opens beside your editor
The extension automatically detects your Python environment in this order:
- VIRTUAL_ENV environment variable (if a virtual environment is active)
- Local .venv folder in your workspace
- Local venv folder in your workspace
- System Python as fallback
Create a simple Streamlit app to test:
import streamlit as st
st.title("Hello Streamlit!")
st.write("This is a test app running in VS Code!")
name = st.text_input("Enter your name:")
if name:
st.write(f"Hello, {name}!")
st.slider("Select a value", 0, 100, 50)Right-click the file and select "Preview Streamlit App" to see it in action.
- "No module named streamlit": Install Streamlit with
pip install streamlit - "python: not found": Ensure Python is installed and in your PATH
- Virtual environment issues: Activate your virtual environment before opening VS Code
- Port conflicts: The extension uses port 8501 by default
MIT License - see package.json for details.
Feel free to submit issues and pull requests to improve this extension.