<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom"><title>Simon Willison's Weblog: virtualenv</title><link href="http://simonwillison.net/" rel="alternate"/><link href="http://simonwillison.net/tags/virtualenv.atom" rel="self"/><id>http://simonwillison.net/</id><updated>2024-09-02T23:57:55+00:00</updated><author><name>Simon Willison</name></author><entry><title>Why I Still Use Python Virtual Environments in Docker</title><link href="https://simonwillison.net/2024/Sep/2/why-i-still-use-python-virtual-environments-in-docker/#atom-tag" rel="alternate"/><published>2024-09-02T23:57:55+00:00</published><updated>2024-09-02T23:57:55+00:00</updated><id>https://simonwillison.net/2024/Sep/2/why-i-still-use-python-virtual-environments-in-docker/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://hynek.me/articles/docker-virtualenv/"&gt;Why I Still Use Python Virtual Environments in Docker&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Hynek Schlawack argues for using virtual environments even when running Python applications in a Docker container. This argument was most convincing to me:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I'm responsible for dozens of services, so I appreciate the &lt;em&gt;consistency&lt;/em&gt; of knowing that everything I'm deploying is in &lt;code&gt;/app&lt;/code&gt;, and if it's a Python application, I know it's a virtual environment, and if I run &lt;code&gt;/app/bin/python&lt;/code&gt;, I get the virtual environment's Python with my application ready to be imported and run.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Also:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;It’s good to use the same tools and primitives in development and in production.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Also worth a look: Hynek's guide to &lt;a href="https://hynek.me/articles/docker-uv/"&gt;Production-ready Docker Containers with uv&lt;/a&gt;, an actively maintained guide that aims to reflect ongoing changes made to &lt;a href="https://docs.astral.sh/uv/"&gt;uv&lt;/a&gt; itself.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://mastodon.social/@hynek/113067230489781151"&gt;@hynek&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/packaging"&gt;packaging&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/virtualenv"&gt;virtualenv&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/docker"&gt;docker&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/hynek-schlawack"&gt;hynek-schlawack&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/uv"&gt;uv&lt;/a&gt;&lt;/p&gt;



</summary><category term="packaging"/><category term="python"/><category term="virtualenv"/><category term="docker"/><category term="hynek-schlawack"/><category term="uv"/></entry><entry><title>import-pypi</title><link href="https://simonwillison.net/2018/Mar/29/import-pypi/#atom-tag" rel="alternate"/><published>2018-03-29T22:16:08+00:00</published><updated>2018-03-29T22:16:08+00:00</updated><id>https://simonwillison.net/2018/Mar/29/import-pypi/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/miedzinski/import-pypi"&gt;import-pypi&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
A devious Python 3 hack which abuses importlib.machinery to add a hook such that any time you type “import modulename” it checks to see if the module is installed and runs “pip install modulename” first if it isn’t. Intended as a joke, but if you habitually fire up temporary virtual environments for exploratory programming like I do this could actually be a neat little time-saver.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/pypi"&gt;pypi&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/virtualenv"&gt;virtualenv&lt;/a&gt;&lt;/p&gt;



</summary><category term="pypi"/><category term="python"/><category term="virtualenv"/></entry><entry><title>Fabric, Django, Git, Apache, mod_wsgi, virtualenv and pip deployment</title><link href="https://simonwillison.net/2009/Jul/28/fabric/#atom-tag" rel="alternate"/><published>2009-07-28T11:56:09+00:00</published><updated>2009-07-28T11:56:09+00:00</updated><id>https://simonwillison.net/2009/Jul/28/fabric/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://morethanseven.net/2009/07/27/fabric-django-git-apache-mod_wsgi-virtualenv-and-p/"&gt;Fabric, Django, Git, Apache, mod_wsgi, virtualenv and pip deployment&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
I’m slowly working my way through this stack at the moment—next stop, fabric.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/apache"&gt;apache&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/deployment"&gt;deployment&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/django"&gt;django&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/fabric"&gt;fabric&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/gareth-rushgrove"&gt;gareth-rushgrove&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/git"&gt;git&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/modwsgi"&gt;modwsgi&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/pip"&gt;pip&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/virtualenv"&gt;virtualenv&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/wsgi"&gt;wsgi&lt;/a&gt;&lt;/p&gt;



</summary><category term="apache"/><category term="deployment"/><category term="django"/><category term="fabric"/><category term="gareth-rushgrove"/><category term="git"/><category term="modwsgi"/><category term="pip"/><category term="python"/><category term="virtualenv"/><category term="wsgi"/></entry><entry><title>Tools of the Modern Python Hacker: Virtualenv, Fabric and Pip</title><link href="https://simonwillison.net/2009/Jul/9/tools/#atom-tag" rel="alternate"/><published>2009-07-09T11:40:58+00:00</published><updated>2009-07-09T11:40:58+00:00</updated><id>https://simonwillison.net/2009/Jul/9/tools/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://clemesha.org/blog/2009/jul/05/modern-python-hacker-tools-virtualenv-fabric-pip/"&gt;Tools of the Modern Python Hacker: Virtualenv, Fabric and Pip&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Ashamed to say I’m not using any of these yet—for Django projects, my manage.py inserts an “ext” directory at the beginning of the Python path which contains my dependencies for that project.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/deployment"&gt;deployment&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/django"&gt;django&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/fabric"&gt;fabric&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/pip"&gt;pip&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/pythonpath"&gt;pythonpath&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/tools"&gt;tools&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/virtualenv"&gt;virtualenv&lt;/a&gt;&lt;/p&gt;



</summary><category term="deployment"/><category term="django"/><category term="fabric"/><category term="pip"/><category term="python"/><category term="pythonpath"/><category term="tools"/><category term="virtualenv"/></entry><entry><title>virtualenv 0.8.1</title><link href="https://simonwillison.net/2007/Sep/15/python/#atom-tag" rel="alternate"/><published>2007-09-15T23:36:42+00:00</published><updated>2007-09-15T23:36:42+00:00</updated><id>https://simonwillison.net/2007/Sep/15/python/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://pypi.python.org/pypi/virtualenv/"&gt;virtualenv 0.8.1&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Ian Bicking’s tool for creating isolated Python environments; designed to replace his earlier workingenv package. Does anyone have any experience using this? It looks fantastically useful.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/ian-bicking"&gt;ian-bicking&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/virtualenv"&gt;virtualenv&lt;/a&gt;&lt;/p&gt;



</summary><category term="ian-bicking"/><category term="python"/><category term="virtualenv"/></entry></feed>