MacOS, Installing Python & pygame

Saturday 21st March, UK – the coronavirus is in full swing, today is the first day in the UK that Restaurants, Pubs, Cafe’s & leisure facilities etc have to stay closed.

So I’ve decided to install Python3 & pygame on my Mac and see what I can do – now I’m more of a Windows guy, so I thought this would be interesting – turns out is was painful.

So, if you want to install Python with Pygame how would I recommend it? Well I think using HomeBrew is the easiest by far.

To do this first you need to install Xcode and Xcode-select, this is done by running the following command:

xcode-select --install

Now, you can run the following to install HomeBrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

For more information see here.

Now HomeBrew is installed, install Python3 by running:

brew install python3

and Java by running:

brew cask install adoptopenjdk

and finally pygame by running:

pip3 install pygame

Now you should be good to go!

Python 3 and SSL: CERTIFICATE_VERIFY_FAILED on MacOS

So I have started to spend more time recently using Python, something I haven’t really used much but it does seem to be a powerful language, and as I’m using Raspberry Pi’s more thought I better look at it.

One of my interests is around AI, or Machine Learning, after installing the required modules and trying to download a demo csv file (for the equivalent Hello World test) I got the following error:

SSL: CERTIFICATE_VERIFY_FAILED

Puzzled… after a little research turns out that by default, in the latter Pythons on MacOS, the certs aren’t installed by default, so if you come across this and need them, do the following.

At the terminal type:

cd "/Applications/Python 3.8/"

Note: you may need to change the Python version in live above, in this line I am using 3.8
Followed by:

sudo "./Install Certificates.command"

That should install the required certificates and not give you the error any more.