In a previous blog post, I’d introduced the usage of “uv” in an existing python environment and demonstrated some benchmarks . But I hadn’t demonstrated how to create a virtual environment using it - as simple as it is.
So this is the article that fills that gap.
First, if you’ve not already installed uv, install it in your global space using
python3 -m pip install uv
This is assuming you have. a version of python3 (preferably > 3.10) installed on your system. If not, that is the first thing you’ll want to do from https://www.python.org/downloads/.
Creating a new virtual environment using ‘uv’ -
Now, uv
works the same way venv
does - i.e. creates a python environment for the project or directory you’re actively in.
So much so, that if you’re in a folder say -
D:\Experiments>
The creation of a new virtual environment is using the command -
D:\Experiments> uv venv
This results in a virtual environment created inside the Experiments directory as a “.venv” directory containing the environment files (libraries, binaries etc).
This environment can then be activated using :
D:\Experiments> .venv\Scripts\activate
Resulting in
(venv) D:\Experiments>
If you’re on WSL or some flavor of Linux , only the activate step changes to -
$ source .venv/bin/activate