
If you’re using pip to install your packages, chances are you have a requirements.txt file in your repository, which may look something like this:
jupyter>=1.1.1
matplotlib>=3.10.7
numpy>=2.3.4
scipy>=1.16.3uv doesn’t handle requirements.txt files. Instead, it leverages a pyproject.toml file and requires you to have dependencies listed in there.
Creating a new pyproject.toml file
If you don’t have a pyproject.toml file, create one first by initializing a new project without any sample code (if you have one, skip this step):
$ uv init --bareThis will provide a file with the following:
[project]
name = "name_of_project"
version = "0.1.0"
requires-python = ">=3.13"
dependencies = []Migrating your requirements from requirements.txt
Then, copy all of the packages listed in your requirements.txt file:
$ uv add -r requirements.txtThis command will copy all of the requirements over and create the uv.lock file, which is a file that stores exact versions to create a reproducible environment for developers on your team:
[project]
name = "name_of_project"
version = "0.1.0"
requires-python = ">=3.13"
dependencies = [
"jupyter>=1.1.1",
"matplotlib>=3.10.7",
"numpy>=2.3.4",
"scipy>=1.16.3",
]Note: I’m not including the uv.lock file here, as this is nearly 2k lines!
At this point, it’s safe to delete your requirements.txt file:
$ rm requirements.txtInstalling dev dependencies from requirements-dev.txt
Say you also have a separate requirements file specific for development (i.e. separated from production code):
black>=25.9.0
isort>=7.0.0
mypy>=1.18.2
pytest>=8.4.2Run the same command, but pass in the --dev flag and your dev text file:
$ uv add --dev -r requirements-dev.txtIn pyproject.toml you’ll see a new section specifically for dev:
[dependency-groups]
dev = [
"black>=25.9.0",
"isort>=7.0.0",
"mypy>=1.18.2",
"pytest>=8.4.2",
]From here, you can use uv like normal to manage your packages.
Happy coding!
📧 Join the Python Snacks Newsletter! 🐍
Want even more Python-related content that’s useful? Here’s 3 reasons why you should subscribe the Python Snacks newsletter:
Get Ahead in Python with bite-sized Python tips and tricks delivered straight to your inbox, like the one above.
Exclusive Subscriber Perks: Receive a curated selection of up to 6 high-impact Python resources, tips, and exclusive insights with each email.
Get Smarter with Python in under 5 minutes. Your next Python breakthrough could just an email away.
You can unsubscribe at any time.
Interested in starting a newsletter or a blog?
Do you have a wealth of knowledge and insights to share with the world? Starting your own newsletter or blog is an excellent way to establish yourself as an authority in your field, connect with a like-minded community, and open up new opportunities.
If TikTok, Twitter, Facebook, or other social media platforms were to get banned, you’d lose all your followers. This is why you should start a newsletter: you own your audience.
This article may contain affiliate links. Affiliate links come at no cost to you and support the costs of this blog. Should you purchase a product/service from an affiliate link, it will come at no additional cost to you.

