It's 10 pm, my chaos monkey mind is thinking about Python, software design patterns, CrossFit, and dogs all at the same time. On top of all of that, I was craving Dominos. Sound's familiar right? 🙃

Recently I had to upgrade Python on my local machine, that led me down the rabbit hole of how homebrew works internally, how to manage environments in Python and wishing I had rbenv for Python. I learned a few things and as per my usual cadence I'm sharing it with the world 🌎

Installing Python

There are a few ways one can install Python onto your machines. It's going to be different depending on your OS but the idea is the same (there might be some other way I don't know of so don't see this list as the one and only way to do it):

  • python.org - download straight from the official website
  • [insert your package manager name] - depending on your OS you're likely going to have access to some sort of a package manager where you can pull python from
  • [insert your IDE name here] - Some IDEs come with pre-packaged python with them. I've been doing a decent amount of ML recently and Anaconda is one of those examples.
Upgrading Python

Now that we have Python installed, there will come a point in time where you want to upgrade your Python version. This is where things become interesting. Here are a few different ways you can do this:

  • Download new version of python from the official website
  • Use your package manager to upgrade your python version
  • Use your IDE to upgrade your python version

But what if you wanted to have multiple versions of python for different projects? 🤔

Enter the world of...

PyEnv

If anyone did Ruby development and had 3+ projects on their laptops they probably stumbled upon some sort of a version manager like rbenv. It's not until a few weeks ago I stumbled upon amazing pyenv

It's super easy to upgrade python versions, have local and global versions etc. There is only one thing that you need to do before installing PyEnv and that is:

Unlink and delete other versions of python you have (unless they are from IDE)

I've spent a decent chunk of time trying to figure out why pyenv's version of python is not being used, where is it on my path and can I have both homebrews and pyenvs at the same time. At the end of the day, I had to delete old versions, unlink them and install pyenv.

Hopefully, this helps and have a great day everyone!

P.S. I'm working on an SSL cert so I can switch to HTTPS (I know long time coming 😬) but just did not get to it yet.