<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.anunna.wur.nl/index.php?action=history&amp;feed=atom&amp;title=Python%2Fuv</id>
	<title>Python/uv - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.anunna.wur.nl/index.php?action=history&amp;feed=atom&amp;title=Python%2Fuv"/>
	<link rel="alternate" type="text/html" href="https://wiki.anunna.wur.nl/index.php?title=Python/uv&amp;action=history"/>
	<updated>2026-08-29T11:22:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.anunna.wur.nl/index.php?title=Python/uv&amp;diff=3066&amp;oldid=prev</id>
		<title>Honfi001: Created page with &quot;{{DISPLAYTITLE:uv}}  uv is a tool for installing Python packages and for managing the environments they live in. It does the same work as &lt;code&gt;pip&lt;/code&gt; and &lt;code&gt;venv&lt;/code&gt;, and it does it a great deal faster.  This page explains what uv is, how to load it on Anunna, where it keeps your files, and how to use it for everyday work. It also explains what uv is &#039;&#039;&#039;not&#039;&#039;&#039; the right tool for: the packages it installs are not built for our hardware, so when the speed of you...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.anunna.wur.nl/index.php?title=Python/uv&amp;diff=3066&amp;oldid=prev"/>
		<updated>2026-08-18T14:27:13Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{DISPLAYTITLE:uv}}  uv is a tool for installing Python packages and for managing the environments they live in. It does the same work as &amp;lt;code&amp;gt;pip&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;venv&amp;lt;/code&amp;gt;, and it does it a great deal faster.  This page explains what uv is, how to load it on Anunna, where it keeps your files, and how to use it for everyday work. It also explains what uv is &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; the right tool for: the packages it installs are not built for our hardware, so when the speed of you...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{DISPLAYTITLE:uv}}&lt;br /&gt;
&lt;br /&gt;
uv is a tool for installing Python packages and for managing the environments they live in. It does the same work as &amp;lt;code&amp;gt;pip&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;venv&amp;lt;/code&amp;gt;, and it does it a great deal faster.&lt;br /&gt;
&lt;br /&gt;
This page explains what uv is, how to load it on Anunna, where it keeps your files, and how to use it for everyday work. It also explains what uv is &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; the right tool for: the packages it installs are not built for our hardware, so when the speed of your calculation matters, the Python modules remain the better choice.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== What uv is ===&lt;br /&gt;
&lt;br /&gt;
uv is a single program that covers work you would otherwise need several separate tools for. On Anunna it is available as a module, already set up for the cluster.&lt;br /&gt;
&lt;br /&gt;
=== What uv does ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! uv can !! Otherwise you would use&lt;br /&gt;
|-&lt;br /&gt;
| Install Python packages || &amp;lt;code&amp;gt;pip&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create and manage environments || &amp;lt;code&amp;gt;venv&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Download other versions of Python || a Python module, if one exists&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== What it is faster at ===&lt;br /&gt;
&lt;br /&gt;
Installing packages, and building the environments that hold them. uv produces the same result as &amp;lt;code&amp;gt;pip&amp;lt;/code&amp;gt; — the very same packages, from the very same place — in a fraction of the time.&lt;br /&gt;
&lt;br /&gt;
That is worth more here than it would be on your own computer. Installing an environment means writing tens of thousands of small files onto a filesystem that everybody on the cluster shares, so finishing sooner is better for you and better for everyone else.&lt;br /&gt;
&lt;br /&gt;
=== What it is not faster at ===&lt;br /&gt;
&lt;br /&gt;
Running your code.&lt;br /&gt;
&lt;br /&gt;
The packages uv installs are general-purpose builds, made to work on any machine in the world. They are exactly what &amp;lt;code&amp;gt;pip&amp;lt;/code&amp;gt; would have given you. The software we provide as modules is compiled for the precise processors in each generation of Anunna&amp;#039;s nodes, and that is where the speed of a calculation comes from. If your work is heavy, use the modules — see [[Python/Modules]].&lt;br /&gt;
&lt;br /&gt;
The same applies to Python itself. uv is able to download a Python for you, but it is a general-purpose build too. The module is set up to use the Python you have loaded rather than fetching one.&lt;br /&gt;
&lt;br /&gt;
=== What we have already set up ===&lt;br /&gt;
&lt;br /&gt;
Left alone, uv keeps its downloads and environments in your home directory, which is small, backed up, and slower than Lustre. The Anunna module points all of it at Lustre instead, and there is nothing you need to do to make that happen. The next two sections cover loading the module and where your files end up.&lt;br /&gt;
&lt;br /&gt;
== Loading uv ==&lt;br /&gt;
&lt;br /&gt;
uv lives in the &amp;#039;&amp;#039;&amp;#039;2025&amp;#039;&amp;#039;&amp;#039; bucket:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
module load 2025 uv&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Loading uv also loads Python 3.13.1, so you do not need to load a Python module first.&lt;br /&gt;
&lt;br /&gt;
Software from different buckets should not be mixed, so anything you use alongside uv should come from the 2025 bucket as well. See [[Environment Modules#Software buckets]].&lt;br /&gt;
&lt;br /&gt;
To check that it worked:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
uv --version&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A second command, &amp;lt;code&amp;gt;uvx&amp;lt;/code&amp;gt;, arrives together with &amp;lt;code&amp;gt;uv&amp;lt;/code&amp;gt;. It is described in [[#Other things uv can do]].&lt;br /&gt;
&lt;br /&gt;
== Where uv keeps your files ==&lt;br /&gt;
&lt;br /&gt;
uv accumulates three kinds of thing as you use it: the packages it has downloaded, any Python versions it has fetched, and the tools you have installed with it. On Anunna the module places all of them on Lustre, under a folder called &amp;lt;code&amp;gt;uv&amp;lt;/code&amp;gt; in your nobackup location — &amp;lt;code&amp;gt;$myNoBkp/uv&amp;lt;/code&amp;gt;. Nobackup is the right tier because everything in there can be downloaded again.&lt;br /&gt;
&lt;br /&gt;
The module does this by setting a handful of variables for you:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable !! What it points at&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;UV_DIR&amp;lt;/code&amp;gt; || The folder that holds all of the others. This is the only one you might want to change.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;UV_CACHE_DIR&amp;lt;/code&amp;gt; || Packages uv has downloaded. Normally the largest of them.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;UV_PYTHON_INSTALL_DIR&amp;lt;/code&amp;gt; || Python versions uv has downloaded.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;UV_TOOL_DIR&amp;lt;/code&amp;gt; || Environments for tools installed with &amp;lt;code&amp;gt;uv tool install&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;UV_TOOL_BIN_DIR&amp;lt;/code&amp;gt; || The programs those tools provide. The module has already added this to your &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;UV_PYTHON_BIN_DIR&amp;lt;/code&amp;gt; || Shortcuts to downloaded Python versions.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Putting them somewhere else ===&lt;br /&gt;
&lt;br /&gt;
Every folder in that table sits inside &amp;lt;code&amp;gt;UV_DIR&amp;lt;/code&amp;gt;, so setting that one variable moves all of them. Set it &amp;#039;&amp;#039;&amp;#039;before&amp;#039;&amp;#039;&amp;#039; loading the module:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
export UV_DIR=$myScratch/uv&lt;br /&gt;
module load 2025 uv&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To see where uv is actually working, ask:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
echo $UV_DIR&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use that rather than &amp;lt;code&amp;gt;$myNoBkp&amp;lt;/code&amp;gt;, which is only set once you have added it to your shell yourself — see [[Installing Personal Software#Aliases and local variables]].&lt;br /&gt;
&lt;br /&gt;
=== Keeping it from growing ===&lt;br /&gt;
&lt;br /&gt;
The cache is meant to grow; that is part of what makes uv fast. It still counts against your Lustre quota, so clear it out from time to time:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
uv cache prune      # remove entries nothing is using&lt;br /&gt;
uv cache clean      # remove everything&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating an environment and installing packages ==&lt;br /&gt;
&lt;br /&gt;
=== Never build an environment on a login node ===&lt;br /&gt;
&lt;br /&gt;
Building an environment writes thousands of small files at once. A login node is shared by every user on the cluster, so that work is felt by all of them rather than only by you. Ask for an interactive session on a compute node and work there:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sinteractive -c 4 --mem 16G --time 120&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See [[Interactive Jobs]] for the options &amp;lt;code&amp;gt;sinteractive&amp;lt;/code&amp;gt; accepts.&lt;br /&gt;
&lt;br /&gt;
=== Creating an environment ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
module load 2025 uv&lt;br /&gt;
uv venv $myNoBkp/PythonEnv/my_env&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Environments belong on Lustre rather than in your home directory, and nobackup is the right tier because an environment can always be built again from the list of packages in it.&lt;br /&gt;
&lt;br /&gt;
If you run &amp;lt;code&amp;gt;uv venv&amp;lt;/code&amp;gt; without giving a path, uv creates a folder named &amp;lt;code&amp;gt;.venv&amp;lt;/code&amp;gt; in whatever directory you happen to be in. Giving the path yourself is clearer, and it keeps your environments together in one place.&lt;br /&gt;
&lt;br /&gt;
=== Using it ===&lt;br /&gt;
&lt;br /&gt;
Activate the environment whenever you want it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
source $myNoBkp/PythonEnv/my_env/bin/activate&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Its name then appears at the front of your prompt:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
(my_env) user001@login200:~$&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install packages into it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
uv pip install numpy pandas&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Leave it again with &amp;lt;code&amp;gt;deactivate&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
What uv builds is an ordinary virtual environment. &amp;lt;code&amp;gt;pip&amp;lt;/code&amp;gt; still works inside it if you prefer, and it can be turned into a Jupyter kernel exactly as [[Python/Modules#Jupyter kernels]] describes.&lt;br /&gt;
&lt;br /&gt;
=== The commands you already know ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! If you know this !! Use this&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;python -m venv my_env&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;uv venv my_env&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;source my_env/bin/activate&amp;lt;/code&amp;gt; || unchanged&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;pip install numpy&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;uv pip install numpy&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;pip list&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;uv pip list&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Other things uv can do ==&lt;br /&gt;
&lt;br /&gt;
=== Running a tool without installing it ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;uvx&amp;lt;/code&amp;gt; fetches a command-line program, runs it, and does not leave an environment behind:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
uvx ruff check .&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Installing a tool you use often ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
uv tool install ruff&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program lands in your uv folder, which the module has already added to your &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt;, so you can run it straight away and in any later session.&lt;br /&gt;
&lt;br /&gt;
=== Using a different version of Python ===&lt;br /&gt;
&lt;br /&gt;
If you need a version of Python we do not provide as a module, uv can fetch one:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
uv python install 3.12&lt;br /&gt;
uv venv --python 3.12 $myNoBkp/PythonEnv/py312&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remember that these are general-purpose builds, like the packages. They are convenient, and they are the right choice when you need a specific version for compatibility — but if the speed of your calculation matters, a Python module is the better starting point.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Do not run &amp;lt;code&amp;gt;uv python update-shell&amp;lt;/code&amp;gt;.&amp;#039;&amp;#039;&amp;#039; It writes a fixed path into your &amp;lt;code&amp;gt;~/.bashrc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;~/.bash_profile&amp;lt;/code&amp;gt;. That applies in every shell you ever open, whether or not the module is loaded, and it stops being correct the moment your uv folder moves.&lt;br /&gt;
&lt;br /&gt;
== Using uv in a job script ==&lt;br /&gt;
&lt;br /&gt;
Build the environment &amp;#039;&amp;#039;&amp;#039;before&amp;#039;&amp;#039;&amp;#039; you submit the job, not inside it. Create it once in an interactive session, as above, and let the job simply use it. An environment built inside the job is rebuilt on every run, and when many jobs start at the same time they all write to the filesystem at once.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH --job-name=myjob&lt;br /&gt;
#SBATCH --time=1:00:00&lt;br /&gt;
#SBATCH --cpus-per-task=4&lt;br /&gt;
#SBATCH --mem=16G&lt;br /&gt;
&lt;br /&gt;
module load 2025 uv&lt;br /&gt;
source $myNoBkp/PythonEnv/my_env/bin/activate&lt;br /&gt;
&lt;br /&gt;
python myscript.py&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Both the &amp;lt;code&amp;gt;module load&amp;lt;/code&amp;gt; and the &amp;lt;code&amp;gt;source&amp;lt;/code&amp;gt; have to be inside the script. A job does not inherit the shell you submitted it from, so anything you loaded by hand beforehand is not there when the job runs. This is the most common reason a script that worked interactively fails under &amp;lt;code&amp;gt;sbatch&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
See [[Batch Jobs]] for what else can go in the &amp;lt;code&amp;gt;#SBATCH&amp;lt;/code&amp;gt; lines.&lt;br /&gt;
&lt;br /&gt;
== FAQ ==&lt;br /&gt;
&lt;br /&gt;
; &amp;lt;code&amp;gt;module load uv&amp;lt;/code&amp;gt; says there is no such module.&lt;br /&gt;
: The bucket has to be loaded first. Use &amp;lt;code&amp;gt;module load 2025 uv&amp;lt;/code&amp;gt;. See [[Environment Modules#Software buckets]].&lt;br /&gt;
&lt;br /&gt;
; Where did uv put my files?&lt;br /&gt;
: &amp;lt;code&amp;gt;echo $UV_DIR&amp;lt;/code&amp;gt; gives the folder they are all under. To hear it from uv itself, &amp;lt;code&amp;gt;uv cache dir&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;uv tool dir&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
; uv warned that it could not find a Lustre directory.&lt;br /&gt;
: The module could not work out where your Lustre folders are, so uv has fallen back to your home directory — which will eventually fill up. Choose a location yourself with &amp;lt;code&amp;gt;export UV_DIR=$myNoBkp/uv&amp;lt;/code&amp;gt; and then load the module again.&lt;br /&gt;
&lt;br /&gt;
; My home directory is still filling up, even though uv uses Lustre.&lt;br /&gt;
: If you used uv before this module existed, an old cache is probably still sitting in &amp;lt;code&amp;gt;~/.cache/uv&amp;lt;/code&amp;gt;. uv no longer looks there, so its own cleaning commands cannot reach it. Check its size with &amp;lt;code&amp;gt;du -sh ~/.cache/uv&amp;lt;/code&amp;gt; and delete it by hand if you no longer need it.&lt;br /&gt;
&lt;br /&gt;
; Can I still use &amp;lt;code&amp;gt;pip&amp;lt;/code&amp;gt; inside a uv environment?&lt;br /&gt;
: Yes. It is an ordinary virtual environment and &amp;lt;code&amp;gt;pip&amp;lt;/code&amp;gt; behaves normally in it.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Python]]&lt;br /&gt;
* [[Python/Modules]]&lt;br /&gt;
* [[Python/Conda]]&lt;br /&gt;
* [[Environment Modules]]&lt;br /&gt;
* [[Installing Personal Software]]&lt;br /&gt;
* [[Interactive Jobs]]&lt;br /&gt;
* [[Batch Jobs]]&lt;br /&gt;
* [[Quotas]]&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
&lt;br /&gt;
* [https://docs.astral.sh/uv/ uv documentation]&lt;br /&gt;
* [https://github.com/astral-sh/uv uv on GitHub]&lt;/div&gt;</summary>
		<author><name>Honfi001</name></author>
	</entry>
</feed>