Nerdsense

UV and and why you dont want to block this python tool

Greg Heffner August 16th, 2025
UV Blog

If you write in python you know there are a few steps that have to be taken when building and running scripts. To be able to clone a repo and run a script without first sourcing and then activating a virtual environment, then using pip to install dependancies has been just a dream until now.

UV is a new tool that is used to replace the numerious steps you would have to take in the past just to be able to run a script. If youre looking for speed, UV is said to be 10-100X faster than pip.

Ill show you why you should to start using it:

If you clone this repo, I have made two very simple API servers. One using pip and one using uv. We can use these as examples to show you not only how fast UV is but if you never created your own API server this will be a double win! API or application programming interface is a way computers exchange information kind of like text messages.

Pip:

In the pip-demo folder you will see 3 items. A readme file explaining what this script does, a requirements file listing all the needed packages for the script to run, and finially the python script itself.

In order to get the API server up and running youll need to do these steps:

pip-script
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python api_server.py

Not too many steps, but enough that you could forget one or two and mess it up. Imagine not remembering to start a virtual environment and instead of installing a package locally for this project, you overwrite the package your system is using. Imagine that new version you installed didnt work well for your device and the problems that it could cause everywhere because of it.

UV:

If you move to the uv-demo folder you will see 2 items. The readme file and the script. Already you can see the savings.

In order to get the API server up and running youll need to do these steps:

uv
uv run api_server.py

Easy peasy. In a World of saving time to focus on whats important this does just that. You dont have to worry about if you remembered to create the virtual environment for your packages, you dont have to worry about remembering to install dependancies before running the script, you dont have to worry about remembering complicated syntax. Plus, UV does more than just install packages locally and run scripts fast.

One-Offs:

What if you are testing something and only want to run a tool once or in an ephemeral environment? UVX does the job. Try it out:

uvx
uvx pycowsay 'Thanks for reading the blog!' You can ignore the SyntaxWarning as the first time a package is installed it has to be compiled and python may show warnings during this time. If you run it again youll see the errors are gone.

Nothing installed permamently, nothing lingering after deletion, just pulled in what the script needs, runs the script, and then removes the data when its gone. A lot easier than pip install and then using python to run a script afterwards.

Projects:

If you are making a project that has multiple files or packages that you are using there are fun ways UV allows you to lock down the code. Using uv lock will lock all packages just incase you try to pull newer versions in the future. This will keep scripts from breaking on newer versions of dependancies. To create a new project and lock the dependancies, all you have to do is "uv init" the project folder.

uv-init
uv init

If you dont have a folder created yet you can create one and init uv at the same time by:

uv init Project-Name-Here
cd Project-Name-Here


Then to add specific packages you would:


uv add flask imports requests

Once you have the packages you want:


uv lock

Thats it! I wanted to share how you could start using this yourself. UV is a great tool that makes our job easier. Give it a go at home with the examples I have in my github repo. Make some scripts, share them with friends. Keep learning!!!

About Me

I served in the U.S. Army, specializing in Network Switching Systems and was attached to a Patriot Missile System Battalion. After my deployment and Honorable discharge, I went to college in Jacksonville, FL for Computer Science. I have two beautiful and very intelligent daughters. I have more than 20 years professional IT experience. This page is made to learn and have fun. If its messed up, let me know. Im still learning :)

Weather Loop

Animated radar loop of Southeast US weather from NOAA