Installing specific version of Python on macOS using home brew

Recently, I was working on some code that required Python 3.6. Although, it would probably run on newer versions of Python, I did not want to take any chances. I wanted to run it on Python 3.6. Normally, I would use a Docker container to ensure a reproducible environment. However, Docker imposes its own complexities when it comes to integrating with IDEs such as Pycharm. A common issue is debugging code when its runtime environment is inside a Docker container. IDEs usually don’t make it easy to create a breakpoint in the IDE and have the code run inside a Docker container. However, if the interpreter and the dependencies are on your host OS, it is easy to set breakpoints and debug code in Pycharm.

Getting back to my issue, I typically use Homebrew on macOS to install packages such as Python. It is a fantastic package manager and I have used it for a very long time now. However, it lacks the feature to install a specific version of a package. In this case, I wanted to install the latest Python 3.6 on my macOS. The only problem was that Homebrew had updated Python to 3.7 and so there wasn’t an easy way to have it install 3.6.

After a bit of digging around, I remembered that Homebrew uses a git repository to store all of its formulae. So, it was a matter of finding the correct Git SHA where the Homebrew maintainers had last updated Python 3.6 and using it to install Python.

Here are the steps I took to install Python 3.6 on macOS using Homebrew and a bit of Git.

First, unlink existing Python

brew unlink python

Next, install Python using the following command

brew install --ignore-dependencies

Here, f2a764ef944b1080be64bd88dca9a1d80130c558 is the Git SHA where I saw the last Python 3.6 update take place in the commit history.

If you’re interested, check out /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula. This is where all the Homebrew formulae live.

PyConSK 2018 Experience

Having worked in Python for over a decade now, I thought it would be a great time to engage the community more meaningfully. I was looking for speaking at various Python events. The first one being the BayPIGGIES event on February 22nd 2018. Later, I was invited to speak at PyCon SK 2018 held in Bratislava from March 9-11 2018. My talk was similar to the one given in BayPIGGIES but slightly different. Public speaking wasn’t always my strengths but it’s always great to push yourself out of your comfort zone to do something new.

PyCon SK 2018 was an interesting experience. I definitely got to meet some really interesting and passionate people. Saw some amazing talks and I’m looking forward to the next year’s event. Of course I got to present my talk which was fantastic. The size of the audience was a bit daunting. I enjoyed meeting the nice folks of Slovakia.

10 easy steps to build MicroPython on macOS for ESP8266

Python Programming Language

I have been playing around with MicroPython for a while now. I enjoy writing straight up C/C++ code but MicroPython has brought the ease of Python to embedded platforms especially ESP8266. ESP8266 and MicroPython make a killer combo.

I’ve written about the ESP8266 and built a couple projects with it already. I’ve built a WiFi temperature sensor using the ESP8266 board that publishes the temperature over MQTT to a central data logging server. It’s a fun project.

Continue reading “10 easy steps to build MicroPython on macOS for ESP8266”

Solution to Pick Peak problem on Codewars

Python Programming Language

Codewars is an interesting website for enhancing your coding skills. I have been playing around with the site for a while trying to get better at Python. I came across the “Pick Peak” problem on codewars that I found very interesting. In this post I’ll take you guys through the Solution to Pick Peak problem on Codewars. The ‘Pick Peak’ problem was fun and interesting. Here’s the problem.

Continue reading “Solution to Pick Peak problem on Codewars”