Made a VS Code extension for running Streamlit apps from the context menu

Hey Streamlit community! :wave:

I made a small VS Code extension that lets you run Streamlit apps directly from the right-click menu. I found myself constantly opening terminals to run different apps during development, so I thought this might be helpful for others too.

It’s pretty straightforward:

  • Right-click any .py file in VS Code

  • Click “Run with Streamlit”

  • The app launches in a new labeled terminal

Each app runs in its own terminal window, so you can have multiple apps running simultaneously without getting them mixed up.

If anyone finds this useful, you can grab it from the VS Code marketplace here:

Requirements are just VS Code (1.93.0+), Python, and Streamlit installed (pip install streamlit).

Let me know if you run into any issues or have suggestions for improvements!

2 Likes

Why do you need a plugin for that?

Why not just create a debug config (.vscode/launch.json) - for either a specific file (for large projects with specific entry point) or for currently opened file - and press F5 to run it? You also get debugging breakpoints that way.

Updated: added sample config:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "debug streamlit",
            "type": "python",
            "request": "launch",
            "program": ".\\.venv\\Scripts\\streamlit.exe",  // "./.venv/bin/streamlit" on linux,
            "args": [
                "run",
                "${file}"   // "${file}" for the current file or specific file with relative path
            ]
        }
    ]
}
1 Like

I agree… on Windows I do it this way and have several of them in my launch.json because I want a selection of server ports (Why? Because I have a personal gists project with dozens of Streamlit apps all on the go… if you know of a way to randomize that port number, please let me know?)

        {
            "name": "Streamlit 4321",
            "type": "debugpy",
            "request": "launch",
            "module": "streamlit",
            "args": ["run", "--server.port", "4321", "${file}"],
            "justMyCode": true,
            "redirectOutput": true,
            "logToFile": true,
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "."
                }
            ]
        },

Omit --server.port and it will start on the first available port up from 8501

I had no idea! Thanks.