<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rick Galbo on Medium]]></title>
        <description><![CDATA[Stories by Rick Galbo on Medium]]></description>
        <link>https://medium.com/@rgalbo?source=rss-55a1db481953------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nYSWQYx35bYib0FYJ7-NZA.jpeg</url>
            <title>Stories by Rick Galbo on Medium</title>
            <link>https://medium.com/@rgalbo?source=rss-55a1db481953------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 22:19:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rgalbo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What is python?]]></title>
            <link>https://medium.com/@rgalbo/what-is-python-d1acd98c43e9?source=rss-55a1db481953------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1acd98c43e9</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[frienship]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[virtual-environment]]></category>
            <category><![CDATA[humor]]></category>
            <dc:creator><![CDATA[Rick Galbo]]></dc:creator>
            <pubDate>Mon, 26 May 2025 05:20:19 GMT</pubDate>
            <atom:updated>2025-05-26T05:26:29.902Z</atom:updated>
            <content:encoded><![CDATA[<p>A story about installing python and managing virtual environments in 2025</p><p>I wrote this piece <a href="https://medium.com/@rgalbo/simple-python-environments-for-data-science-globe-with-meridians-2b952a3f497f">Simple Python Environments for Data Science</a> in 2017. I was looking for a job, I was at my aunt and uncles house in Winchester, NH. It was a dewy morning, I was up early and had some coffee. I was excited because that day I was going to formalize what I knew to be true about virtual environments. At that time it was simple. Use base python (avoid anaconda), use simple virtual environments, everything works perfectly.</p><p>But hold on, life happened.</p><p>Fast forward to now. It is 2025, the world is burning, I am sitting at a desk clacking away on Memorial Day Eve. I am once again applying for a job. I work for a bank, a big one. I don’t program at said bank, as I am non-tech designated and they don’t like us normies clacking on projects. I am being recruited to another bank, a small one. They have a data science team of 9 who manages a banks worth of operations. That sounds exciting. They use Snowflake, Sagemaker and of course the beautiful PowerBI. I haven’t used these for some time so I wanted to preemptively make a project to showcase my abilities for them.</p><p>The project is called GridSource and you can find it <a href="https://github.com/rcgalbo/GridSource">here</a>.</p><p>I make this beautiful project and I created notebooks to test the data extraction pieces and test the components of the Airflow pipeline. All good and well intentioned. I installed the package that I had created, bop open a ipython console, test import the package that I created, and voila everything imports as expected.</p><p>Back in the jupyter notebook things go terribly. It seems like the jupyter kernel cannot find gridsource .</p><p>Fuck.</p><p>Pip list and the previous ipython test reveal that it is in fact installed in the environment.</p><p>I print out the python version being used by jupyter. It is the correct version from the environment.</p><p>When I print out the python path, this is when things get a little wonky. The first 3 items on the python path are .pyenv shims.</p><p>The only reason I have pyenv on my computer is that I took a course last fall and they use pipenv a package developed by Kenneth Reitz (creator of requests). Pipenv is cool and if you install this software called pyenv when you create a new pipenv you can choose what version of python you want that environment to be. Cool so in your head imagine a home directory with a .pyenv folder and in that folder lives a bunch of pythons, lets call it a bag of snakes because that is what it is.</p><figure><img alt="Baggage full of many snakes, oh yes you heard that right there are snakes in the bag. They are not outside the bag, they are inside the bag. The bag is mesh and see through so you can see all of the snakes and oh boy yes can I say again that this is a mesh bag full of snakes." src="https://cdn-images-1.medium.com/max/1024/1*ivGDvFq9EA0OdSi7cvAA3g.png" /><figcaption>Bag of Snakes</figcaption></figure><p>This bag of snakes (BOS) is what is shimmed to you at the very moment you decide to create a new pip env with pyhon 12.12.12 or whatever. Pipenv enviroments do this wild thing where they auto-activate in the directory their pipfile lives. They also take forever. I appreciate the effort that went into it but just no.</p><p>So I check that pretty much every python installation that has ever touched my computer is loaded before the virtual environment that has my package installed. Literally the only thing I care to use is not in the running.</p><p>A lot of you are going to comment on this saying that jupyter has it’s own environment and you need to add the python package to the path before you import it.</p><p>Fellas, its 2025. If jupyter hasn’t figured out the workflow of the following:</p><pre>$ python3 -m venv venv<br><br>$ source ./venv/bin/activate/python<br><br>$ uv pip install jupyter mypackage<br><br>$ jupyter lab</pre><p>Then I simply don’t know what to say. So no to stack overflow and claude, I will not be prepending my virtual environment to my python path every time I want to use code in a package, which is pretty much the only way to import python code unless you are a monorepo madman(woman) who likes that kind of thing.</p><p>That is not a fix, that is a hack. Why we allow ourselves to let our computers make these choices for us is frustrating. Of course I was dumb enough to convince myself that writing a script in my .bashrc to auto append the pytest to the system python path was a good idea. Let me tell you something. If I was playing ball with the pipenv ecosystem, it might not be a problem. But I just wrote above the workflow. It is simple and clean. It does what I want, when I want it to be done, and that makes me happy because I am simple and tired and just want things to work.</p><p>In a perfect world in 2025 would I appreciate to be able to use multiple versions of python to create virtual environments? Yes I would like that very much.</p><p>But here is the thing, which python you python with doesn’t matter all that much.</p><p>Below I used AI (get over yourselves) to generate every major improvement added to python in every major semantic version update:</p><h3>Python 1.x (1991–2000)</h3><ul><li><strong>Python 1.0</strong> (January 1994) — First major release with core language features</li><li><strong>Python 1.6</strong> (September 2000) — Final 1.x release</li></ul><h3>Python 2.x (2000–2020)</h3><ul><li><strong>Python 2.0</strong> (October 2000) — Introduced list comprehensions, garbage collection</li><li><strong>Python 2.7</strong> (July 2010) — Final 2.x release, maintained until January 2020</li></ul><h3>Python 3.x (2008-present)</h3><ul><li><strong>Python 3.0</strong> (December 2008) — Major breaking changes, print function, Unicode by default</li><li><strong>Python 3.1</strong> (June 2009) — Performance improvements</li><li><strong>Python 3.2</strong> (February 2011) — Added argparse, concurrent.futures</li><li><strong>Python 3.3</strong> (September 2012) — Added yield from, venv module</li><li><strong>Python 3.4</strong> (March 2014) — Added asyncio, pathlib, enum</li><li><strong>Python 3.5</strong> (September 2015) — Added async/await, type hints</li><li><strong>Python 3.6</strong> (December 2016) — Added f-strings, variable annotations</li><li><strong>Python 3.7</strong> (June 2018) — Added dataclasses, improved asyncio</li><li><strong>Python 3.8</strong> (October 2019) — Added walrus operator (:=), positional-only parameters</li><li><strong>Python 3.9</strong> (October 2020) — Added union operators for dicts, improved type hints</li><li><strong>Python 3.10</strong> (October 2021) — Added match/case statements, union types with |</li><li><strong>Python 3.11</strong> (October 2022) — Significant performance improvements, better error messages</li><li><strong>Python 3.12</strong> (October 2023) — Added f-string improvements, per-interpreter GIL</li><li><strong>Python 3.13</strong> (October 2024) — Experimental free-threaded mode, improved REPL</li></ul><p>So look, this is what we are working with. If someone needs you to rip a 2.7 project, say no and tell them to stop playing jurassic park. If you use 3.12 all of python3 is backwards compatible so you get all of the previous features, wild I know, in the newest version and they WORK!</p><p>So my excitable self solved a problem that didn’t need solving and now has put me into a pickle.</p><p>I think this is more a parable about chasing shiny new things. The above workflow is all you need. If someone tells you otherwise, they are silly and young, or they are old and silly, but mostly one of those two things.</p><p>So if you see me at my local coffee shop wearing a dunce cap, now you know why.</p><p>Tomorrow I will fix this insanity.</p><p>Tonight I will sleep.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1acd98c43e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple Python Environments For Data Science ]]></title>
            <link>https://medium.com/@rgalbo/simple-python-environments-for-data-science-globe-with-meridians-2b952a3f497f?source=rss-55a1db481953------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b952a3f497f</guid>
            <category><![CDATA[jupyter-notebook]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[virtual-environment]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[anaconda]]></category>
            <dc:creator><![CDATA[Rick Galbo]]></dc:creator>
            <pubDate>Fri, 24 Nov 2017 05:38:10 GMT</pubDate>
            <atom:updated>2019-03-18T15:27:54.904Z</atom:updated>
            <content:encoded><![CDATA[<p>Python environments have long been one of the most confusing and annoying parts of a python work flow for data scientists (or anyone really). The lack of a clear and concise explanation for environments was recently brought to my attention by this tweet:</p><h3>Andreas Mueller on Twitter</h3><p>Is there a good succinct guide to how to figure out which Python environment you&#39;re in and how to install stuff in the right environment that&#39;s suitable for beginners? cc @jakevdp (also if there&#39;s not Jake, can you write one ;)</p><p>While I’m no <a href="https://twitter.com/jakevdp">Jake VanderPlas</a>, I am someone who has always struggled with python environments and definitely see the need for a clear and concise explanation of environments. Here you will find a simple guide explaining what virtual environments are and how make them to work.</p><h3>Goals</h3><ol><li>Explain wtf a virtual environment is ❓</li><li>Explain how to create and use virtual environments 😆</li><li>Get a jupyter notebook up and running inside a virtual environment 😎</li></ol><h3>WTF is a virtual environment</h3><p>Python virtual environments allow you to wade through the shitshow that is installing python packages. There are two very common python package managers that most people in data science use pip and conda.</p><p>pip: a python tool for installing packages from Python Package Index <a href="https://pypi.python.org/pypi">(PyPI</a>)</p><p>conda: package manager for the anaconda python distribution which has quickly become defacto for data science due to its user-friendliness (<em>disclaimer: I use anaconda as my python distribution</em>)</p><p>It can be simple to install packages with these tools (sometimes) but we have all gotten awful and confusing pip errors!. There is also the issue of packages that require different versions same dependency, or packages that don’t even work with the version of python that you are using.</p><p>This is where virtual environments come in handy.</p><p><strong>Virtual environments allow you to create different versions of python with packages specific to each project that you are working on</strong>. When you create a new virtual environment you are specifying the versions of python and a versions of the packages you need in order to prevent those awful import errors we all hate.</p><h3>Creating and Using Virtual Environments</h3><p>So now that we know about virtual environments and feel they are marginally important lets look at two tools to create and manage virtual environments.</p><h4><a href="https://www.anaconda.com/download/">Anaconda</a></h4><p>Anaconda uses the conda package manager. conda has a very simple api for creating environments.</p><pre>$ conda create --name &lt;environment_name&gt; python=&lt;version_of_python&gt;</pre><p>This command will create a new environment located inside of the anaconda directory ~/anaconda/envs/[environment name]/ . When creating a anaconda environment you can include package names as arguments:</p><pre>$ conda create --name test_env --python=3 numpy pandas scikit-learn</pre><p>This will create a new environment called test_env the packages numpy, pandas, and sklearn installed already. To use the shiny new environment that you just created you simply run:</p><p><strong>mac/linux:</strong> $ source activate &lt;environment name&gt;</p><p><strong>windows: </strong>$ activate &lt;environment name&gt;</p><p>When you are in the conda environment you can conda install any required packages or if those packages aren’t available through conda channels you can also pip install packages like you would normally.</p><p>To view the installed packages in your current environment you can run conda list which will print out the packages.</p><h4>How do I know what environment I’m in</h4><p>To view all of your environments run command conda info -e which will return a list of your environments and place a star next to the current environment. When you activate your virtual environment it will change your prompt so that the name of your virtualenv is at the beginning of your prompt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0chdhenef3K7qcAp7NDNUQ.png" /><figcaption>Here I am activating my conda environment `dl` and running conda info</figcaption></figure><h4><a href="https://docs.pipenv.org/">Pipenv</a></h4><p>If you have animosity towards authoritarian open sourced, or just want to work with straight PyPI packages there is a new option in pure python. <strong>Pipenv </strong>is the new cool kid on the block for managing python virtual environments courtesy of <a href="https://twitter.com/kennethreitz">Kenneth Reitz</a>. Unlike Anaconda which is geared toward scientific computing, Pipenv is built with python development in mind, specifically networking. This means that it doesn’t come with any built in features but works incredibly well and is fairly simple to use plus it has a really pretty cli. Pipenv is built to be a replacement for pip and virtualenv to create a simpler work flow for creating environments in python.</p><p>Creating an environment is very simple:</p><pre>$ pipenv install &lt;package names&gt;</pre><p>Thats it! This creates a virtual environment and installs the packages that were specified. A few things to note here, unlike creating an environment in anaconda, there is no name to be set. The environment will just take the name of the directory that it is created in.</p><p>To activate the environment you will simply run pipenv shell <strong>inside the project directory</strong> and viola you are in your shiny new Pipenv. To install new packages into your environment simply run pipenv install [package name] while the project is active.</p><p>Pipenv will store package info in a file called a Pipfile that will look something like this:</p><pre>$ pipenv install numpy pandas scikit-learn</pre><pre>$ cat pipfile<br>[[source]]<br>url = &quot;https://pypi.python.org/simple&quot;<br>verify_ssl = true<br>name = &quot;pypi&quot;<br><br>[packages]<br>numpy = &quot;*&quot;<br>pandas = &quot;*&quot;<br>scikit-learn = &quot;*&quot;</pre><pre>[dev-packages]</pre><p>You can also view package information by running pip list from inside an active environment.</p><h3>Installing and Running Jupyter</h3><p>Now that we have a few options to create and manage virtual environments we will demonstrate creating and using the environments to get a jupyter notebook installed and ready for data science action.</p><h4>Jupyter with Anaconda</h4><p>By running three commands we can get a jupyter notebook running in an environment that is ready for action.</p><pre># create the environment<br>$ conda create -n jupyter_env python=3 jupyter</pre><pre># activate the environment (mac/linux version)<br>$ source activate jupyter_env</pre><pre># launch a notebook server in our env<br>$ jupyter notebook</pre><p>That is all! Super simple, super concise and it ‘just works’ which will save your time for all the super fun data munging you need to do before you can run models or make pretty data pictures. Now any time you want to work in a jupyter notebook you simply activate the environment and launch it in your project of choice.</p><h4>Jupyter with Pipenv</h4><p>Similar to anaconda, we can create a Pipenv fairly simply.</p><pre># create a project directory<br>$ mkdir jupyter_project</pre><pre># change into the project directory<br>$ cd jupyter_project</pre><pre># create your pipenv<br>$ pipenv install jupyter</pre><pre># activate the environment<br>$ pipenv shell</pre><pre># launch a notebook server in our env<br>$ jupyter notebook</pre><p>Just two more steps but thats all we need to get up and running with pipenv. The nice thing about pipenv is that we can install it using pip.</p><p><strong>Note - </strong>The biggest drawback of Pipenv is that the cli doesn’t allow global environment access which means you cant just run $ pipenv shell from anywhere, it will only work from inside the project folder. However, all the environments are located in a directory ~/.local/share/virtualenvs/ so to activate them from other directories all you need to do is run:</p><pre># list the virtual environments<br>$ ls ~/.local/share/virtualenvs/</pre><pre># activate the environment from afar<br>$ source ~/.local/share/virtualenvs/[environment_name]/bin/activate</pre><h3>Future posts 🔮</h3><p>Now that we’ve covered the basics of setting up simple environments for data science, there are some other important topics to cover. One of them is sharing your environments with others so that they can reproduce your code and interact with your research. Another important tool to cover is the actual jupyter notebook itself. There are many underutilized features of Jupyter notebooks that make machine learning projects much simpler.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b952a3f497f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>