<?xml version="1.0" encoding="utf-8"?> 
<rss version="2.0">
 <channel>
  <title>Will Lachance&#39;s Log: Posts tagged &#39;python&#39;</title>
  <description></description>
  <link>https://wrla.ch/tags/python.html</link>
  <lastBuildDate>Thu, 26 Feb 2026 17:17:43 GMT</lastBuildDate>
  <pubDate>Thu, 26 Feb 2026 17:17:43 GMT</pubDate>
  <ttl>1800</ttl>

  <item>
   <title>`uv run` isn&#39;t always what you want</title>
   <link>https://wrla.ch/log/2026/02/uv-run-isn-t-always-what-you-want/?utm_source=python&amp;utm_medium=RSS</link>
   <guid isPermaLink="false">urn:https-wrla-ch:-log-2026-02-uv-run-isn-t-always-what-you-want</guid>
   <pubDate>Thu, 26 Feb 2026 17:17:43 GMT</pubDate>
   <author>Will Lachance</author>
   <description>
&lt;p&gt;Like many others, I&#39;ve joined the cult of &lt;a href=&#34;https://docs.astral.sh/uv&#34;&gt;uv&lt;/a&gt;. One superpower is that you no longer really need to think of activating a virtual environment in a project managed with this tool, &lt;code&gt;uv run path/to/script.py&lt;/code&gt; will do the right thing.
You don&#39;t have to think about whether the virtual environment exists or is up to date, uv takes care of that under the hood and then runs your script inside the environment.&lt;/p&gt;
&lt;p&gt;This is &lt;em&gt;great&lt;/em&gt; for local development but isn&#39;t generally what you want if:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;You&#39;re running a service inside a docker container and the virtual environment is already created (you ideally shouldn&#39;t even have uv installed)&lt;/li&gt;
&lt;li&gt;You&#39;ve created a standalone tool with a virtualenv and just want to run it by itself (and not develop it).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For these cases, generally either set your path to include the virtual environment created by uv (&lt;code&gt;/prefix/.venv/bin&lt;/code&gt;) or just run the script directly (&lt;code&gt;/prefix/.venv/bin/script.py&lt;/code&gt;). &lt;code&gt;uv run&lt;/code&gt; has startup overhead and inside a docker container, you also don&#39;t &lt;em&gt;want&lt;/em&gt; to dynamically download a bunch of new things: you just want to use
what you already created.&lt;/p&gt;
&lt;p&gt;tl;dr: &lt;code&gt;uv run&lt;/code&gt; is for development. Just execute the actual script in production.&lt;/p&gt;
</description></item>
</channel></rss>