uv run --with numpy==2.0 myfile.py
What happens under the hood?
When you run uv run
using --with
, uv
contacts PyPI and tries to download the requirement you’ve named and the appropriate version if you’ve supplied one. If the requirement is provided as a wheel, it’ll use that; if not, it’ll obtain the source and try to compile it for your current platform.
Next, uv
caches the resulting download in the directory found in your user profile. After that, the program you selected will run with the downloaded requirements.
The first time uv
fetches a requirement from PyPI, you’ll see feedback about the download process in the console. Depending on how many requirements there are and how big they are, this may take some time. But on subsequent runs, if you ask for the same requirements, they’ll be obtained out of the local cache, and so will start almost instantly.