CARVIEW |
A New Python Package Manager
Manage Python projects, run scripts and tools, handle dependencies, and install packages—all with the uv tool.

Image by Author
uv is a fast Python package and project manager, written in Rust. It can be used instead of pip, pip-tools, pipx, poetry, pyenv, and virtualenv tools. uv provides a complete ecosystem for managing Python projects, allowing you to add dependencies, manage tools, run scripts, and more. In short, from installing Python to building Python applications, uv makes the process faster and easier. One of the best features of uv is its compatibility with the pip tool. This means that you just need to add "uv" in front of your command and all of your previous commands will work out of the box.Â
In this tutorial, we will learn how to install uv and explore its various features. We will create a project, add dependencies, run scripts, use tools, and also learn about its pip interface.
Installing uv
You can run the following command in the terminal to install uv in Linux and MacOS.
$ curl -LsSf https://astral.sh/uv/install.sh | sh
For Windows, try using the Winget tool.
$ winget install --id=astral-sh.uv -e
It is so flexible that you can install it using the pip interface.Â
$ pip install uv
After the installation is completed, run the `uv` command in the terminal to check whether it is properly installed.
$ uv
Projects
We will now initialize the Python project called "KDN."
$ uv init KDN
Change the directory to the project.Â
$ cd /datasets/_deepnote_work/KDN
As you can see, the project has all the necessary files.

We will run the sample Python file using the `run` command.Â
$ uv run hello.py
As we can see, it first created the virtual environment folder and then ran the Python file.Â
Creating virtual environment at: .venv
Hello from kdn!
We will proceed with installing and adding 'pandas' as a dependency to the project.Â
$ uv add 'pandas==2.2.3'

Scripts
Now, we will learn how to run Python file more easily with uv. First, we will create a simple web scripting Python file with the necessary code.
$ echo "import requests; from bs4 import BeautifulSoup; response = requests.get('https://www.kdnuggets.com/author/abidali-awan'); soup = BeautifulSoup(response.content, 'html.parser'); print('Webpage Title:', soup.title.string)" > webscrape.py
We will then add the dependencies to the web scripting file.
$ uv add --script webscrape.py "requests" "beautifulsoup4"
These dependicing will be added to the file as a comment and only be read by the uv tool.

Â
When you run the Python file, it will first install the Python packages and then run the code.Â
$ uv run webscrape.py
Output:
Installed 7 packages in 18ms
Webpage Title: Abid Ali Awan - KDnuggets
This is quite useful if you work outside the project and have only a few Python files to run.Â
Tools
We can install and use CLI tools using the `uv` command. In our case, we are installing the `huggingface_hub` tools, which allow us to pull and push files from Hugging Face repositories.
$ uv tool install huggingface_hub
To view all the installed tools, we can run the following command. Â
$ uv tool list
We have installed the tool, but as you can see, it has a different name, "huggingface-cli," for running the command.
huggingface-hub v0.25.1
- huggingface-cli
To run the tool with a different name from the package name, we will use the `--from` flag and provide it with the package name and the tool name. Then, we will log in to Hugging Face Hub using the API key.Â
$ uv tool run --from huggingface-hub huggingface-cli login --token $HUGGINGFACEHUB_API_TOKEN
The tool works.Â
Your token has been saved to /root/.cache/huggingface/token
Login successful
The pip Interface
uv is fully compatible with the pip tool, meaning we can run all the pip commands using the uv tool. All you have to do is add `uv` at the start of your script.Â
We will install the `controlflow` package using the pip interface.
$ uv pip install controlflow -q
Then, we will view its description using the `show` command.Â
$ uv pip show controlflow
Name: controlflow
Version: 0.10.0
Location: /root/venv/lib/python3.9/site-packages
Requires: jinja2, langchain-anthropic, langchain-core, langchain-openai, markdownify, openai, prefect, pydantic-settings, textual, tiktoken, typer
Required-by:
In the end, we will create the `requirements.txt` using the freeze command.
$ uv pip freeze >> requirements.txt
Final Thoughts
uv is suitable for beginners, portfolio projects, and production-ready projects. It is becoming increasingly popular, with many orchestration tools replacing pip with uv and encouraging users to make the switch to this superior tool.
In my opinion, uv is better than pip when dealing with large projects with hundreds of dependencies. However, for small projects, I believe that pip tool is still superior in terms of speed and efficiency.
In this tutorial, we have learned about the new Python project management tool. We have also explored its features with code examples such as Project, Scripts, Tools, and the Pip interface.
Abid Ali Awan (@1abidaliawan) is a certified data scientist professional who loves building machine learning models. Currently, he is focusing on content creation and writing technical blogs on machine learning and data science technologies. Abid holds a Master's degree in technology management and a bachelor's degree in telecommunication engineering. His vision is to build an AI product using a graph neural network for students struggling with mental illness.
- Data Scientist, Data Engineer, or Technology Manager: Which Job Is…
- If Data is the New Oil, then Generative AI is the New Rocket Fuel
- ChatGPT Dethroned: How Claude Became the New AI Leader
- skops: A New Library to Improve Scikit-learn in Production
- DataLang: A New Programming Language for Data Scientists... Created…
- Falcon LLM: The New King of Open-Source LLMs
Latest Posts
- We Benchmarked DuckDB, SQLite, and Pandas on 1M Rows: Here’s What Happened
- Prompt Engineering Templates That Work: 7 Copy-Paste Recipes for LLMs
- A Complete Guide to Seaborn
- 10 Command-Line Tools Every Data Scientist Should Know
- How I Actually Use Statistics as a Data Scientist
- The Lazy Data Scientist’s Guide to Exploratory Data Analysis
Top Posts |
---|
- 5 Fun AI Agent Projects for Absolute Beginners
- How I Actually Use Statistics as a Data Scientist
- The Lazy Data Scientist’s Guide to Exploratory Data Analysis
- Prompt Engineering Templates That Work: 7 Copy-Paste Recipes for LLMs
- We Benchmarked DuckDB, SQLite, and Pandas on 1M Rows: Here’s What Happened
- 10 Command-Line Tools Every Data Scientist Should Know
- A Gentle Introduction to TypeScript for Python Programmers
- A Complete Guide to Seaborn
- From Excel to Python: 7 Steps Analysts Can Take Today
- A Gentle Introduction to MCP Servers and Clients