Python Project Setup with uv
There are many different ways to get started with a Python project. You can create a new directory and use the python
executable in your path, or you can use virtualenv to isolate your development environment from your default python environment. Then there are environment management tools, such as poetry, that help you manage dependencies, virtual environments, and project packaging all in one tool. The latest of these tools is uv, which manages project dependencies and environments, with support for lockfiles, workspaces, and more.
Let's see how to get started with uv and create a starting point for an easy-to-use development environment.
First, install uv with Homebrew; other instructions are on their installation page.
brew install uv
Now, let's set up the project directory and use python 3.13
uv init -p 3.13 python-uv-example
This creates for us a python-uv-example directory and the following files:
.
├── main.py
├── pyproject.toml
└── README.md
1 directory, 3 files
It creates a simple main.py
:
def main():
print("Hello from python-uv-example!")
if __name__ == "__main__":
main()
that we can run right away:
uv run main.py
Using CPython 3.13.5 interpreter at: /opt/homebrew/opt/python@3.13/bin/python3.13
Creating virtual environment at: .venv
Hello from python-uv-example!
as well as an empty README.md
file and the pyproject.toml
is already configured.
[project]
name = "python-uv-example"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = []
Git is also set up for us as well as a simple .gitignore
file.
All we need to do is to commit our code:
git add .
git commit -m "First checkin" -a
Now we have a project set up a python project with uv.
I've shared this project on github as an example: https://github.com/markcallen/python-uv-example