How to use Streamlit with UV and VSCode
With this tool, you can streamline your Streamlit development with UV and VSCode
How to use Streamlit with UV and VSCode
With this tool, you can streamline your Streamlit development with UV and VSCode
UV, VSCode and Streamlit logos, copyright individual owners
Getting started with a new Streamlit project is simple: create an environment, install your dependencies, open VSCode, make sure that VSCode knows how to start a Streamlit app, and start building.
OK, so in practice, combining Streamlit, UV, and VSCode into a smooth workflow involves a handful of setup steps that you need to repeat each time you start a new project.
To make that process easier, I’ll describe a script you can download that automates the workflow. The script prompts you for your project name, creates a virtual environment with that name, installs the correct version of Python and the required libraries, creates a simple Streamlit app, and configures a ready-to-use “Run” command inside VSCode so you can launch your app immediately.
Whether you’re working on Linux, macOS, or Windows, this tool helps you skip the tedious setup and jump straight into development. Below, I’ll walk through how the script works, how to use it, and how it can streamline your Streamlit setup process.
It’s not a big problem, but…
No matter whether you are an experienced Streamlit developer or a beginner, if you want to easily use a UV-powered virtual environment and use VSCode to write your code, you need to type in a bunch of command-line prompts to get going. And even then, VSCode doesn’t know how to start a Streamlit app, especially one in a UV virtual environment.
There is a simple solution.
What we need is a script that will:
- Initialise a UV project, with a preferred version of Python, in a new folder
- Move to that folder
- Install streamlit and any other required libraries
- Add a local configuration file to add a run command, uv run streamlit run, to VSCode
- Add a barebones Streamlit app
- Start VSCode
Walkthrough
It’s probably best to work in a project folder in which you can create new project sub-folders.
First, we need UV and VSCode installed.
1. UV
Full instructions for installation are on the Astral website, but basically:
Linux/Mac
curl -LsSf https://astral.sh/uv/install.sh | sh
or
wget -qO- https://astral.sh/uv/install.sh | sh
Windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
2. VSCode
Comprehensive instructions on how to download, install and set up VSCode can be found on their website (not difficult but too long to include here).
3. Set your environment
Make a projects directory and download the script into it. You can find the script file in the repo — you can download or clone the entire repo (you’ll get both versions of the script and a descriptive README.md) .
Alternatively, just download the script that you need. The scripts are called setup-streamlit.sh(Linux/Mac) and setup-streamlit.bat(Windows). (If you think the name requires too much typing, by all means, rename it). In the repo, navigate to the appropriate file and download it individually.
4. Run the script
In the project directory and in a terminal window, start the script.
Below, we can see the script running in Linux. You should get pretty much the same result in Windows, but you will need to invoke it thus: ./setup-streamlit.bat.
$ bash setup-streamlit.sh
Enter project name [myproject]: project1
Enter Python version [3.13]: 3.12
Streamlit will be installed by default.
Enter additional libraries to install (space-separated) [none]: pandas
Project Summary:
----------------
Project Name: project1
Python Version: 3.12
Libraries: streamlit pandas
----------------
Proceed with these settings? (y/n):
As you can see, you are asked to provide a name, a Python version, a list of libraries and then to confirm your choices. If you choose anything other than ‘y ’, then the script will stop. Otherwise, you’ll see something like the following:
Initializing project projects1...
Initialized project `projects1` at `/Projects/projects1`
Adding libraries: streamlit pandas...
Using CPython 3.12.3 interpreter at: /usr/bin/python3.12
Creating virtual environment at: .venv
Resolved 45 packages in 329ms
Prepared 7 packages in 9.96s
Installed 42 packages in 54ms
+ altair==6.1.0
+ anyio==4.13.0
+ attrs==26.1.0
+ blinker==1.9.0
... most library installations have been deleted for brevity
Configuring VSCode tasks...
Setting up main.py...
Opening project in VSCode...
The new project will be created with a .vscode folder and a tasks.json file. VSCode will then be invoked from the project.
Select main.pyand you'll see a simple Streamlit app. To run it, select View/Command -palette or hit Ctrl+Shift+P, and select Run tasks from the drop-down menu. You may need to scroll down to see the correct entry, but once you've used it, it will appear at the top of the menu next time.
Now, select Streamlit: Run Current File, and the app will run as expected in a browser — no need to open a terminal window.
Now you are ready to add your application code.
Do I need a UV extension for VSCode
No, not really.
Although there is no harm in adding one, I feel that they are of limited value, as most seem to simply mimic UV commands in the Command Palette. My view is that it is as easy to open a terminal window and type in the UV command. If, for example, you forgot to add a library, just type uv add numpy (for example), in a terminal window.
The exception is the run command, where the Command Palette shortcut set up by our script replaces the rather long, uv run streamlit run <filename>. Maybe you might want to use other UV commands which are as unwieldy. In that case, you might consider an extension - otherwise I wouldn't bother.
Conclusion
This simple script saves time, ensures a consistent setup and avoids errors from typos. You can develop your Streamlit app in VSCode and run it directly from there without the need to open a terminal window (unless you’ve forgotten to add a library).
The script was initially developed for Bash (Linux or Mac) but has been translated into a Windows batch file. It’s MIT-licensed, so by all means, copy and adapt it if you think it could be improved. If you do, please leave a comment here.
Thanks for reading. Personally, I find the script useful, and I hope you do too. If you want to see more of my work, please follow me here on Medium or subscribe to my occasional newsletter.
Links
- GitHub Repo: stuvvs
메타데이터
- post_id
- 492622f2222f
- slug
- how-to-use-streamlit-with-uv-and-vscode-492622f2222f
- url
- https://medium.com/codefile/how-to-use-streamlit-with-uv-and-vscode-492622f2222f
- canonical_url
- https://medium.com/codefile/how-to-use-streamlit-with-uv-and-vscode-492622f2222f
- author_url
- https://medium.com/@alan-jones
- status
- ok
- fetched_at
- 2026-06-09 15:37:30