Python3 setup on OSX/MacOS High Sierra

By default MacOS has Python 2.7 installed out of the box, however for my PhD project I am using a number of libraries that require Python 3.x.x. There are numerous approaches to deploy multiple versions of Python to MacOS, so I’ve documented the approach I took.

A big thanks to Chris Mendez, as my approach is based on his article: Installing Multiple versions of Python on Mac using Home-brew

I already had Homebrew installed, but incase you haven’t there is a tutorial on Installing Homebrew for Mac. I’ve tried a number of approaches using VirtualEnv and found that PyEnv seems to do the job much better. The steps as follows:

brew install pyenv
echo ‘eval “$(pyenv init -)”‘ >> ~/.bash_profile
. ~/.bash_profile

I then looked for the lastest version of python (version 3.6.5) and installed it using PyEnv, and switched the local and global environmenal settings to point to it.

pyenv install 3.6.5

The next problem was to install all the modules currently loaded on the MacOS provided version of Python (version 2.7.10) the local and global environmenal settings to point to it. So before switching to the new version, I used ‘pip‘ to extract the list to a file, ‘/tmp/2.7-module.list’. I then edited the file, to remove any version 2 specific modules, also I removed ‘MySQL-python’ as it has been replaced with a nice shiny pure python MySQL client library ‘PyMySQL’, and I’d had problems with it.

pip list > /tmp/2.7-module.list
– edit the file to remove unwanted modules –
pyenv global 3.6.5

for l in `cat /tmp/2.7-modules.list | awk ‘{ print $1 }’`;do
 pip install $l;

Make note of which modules were installed sucessfuly and if there are any errors.

Just a quick note on ‘PyMySQL’. I have installed both client and server on my Mac, so I did’t experence library dependencies. The reason was that I’d previously had great fun trying to install ‘MySQL-python’ without MySQL server installed locally, and in the end gave and installed it. For this reason I’m guessing I didn’t have any problems installing ‘PyMySQL’.

I ran into a problem and originaly needed to use ‘sudo pip‘ to install modules for the system version of Python, as the libriaries were installed in the system library. This is no longer required with PyEnv as all the libraries as installed under ‘~/.pyenv/‘ tree.

Quick reference:

pyenv versions         – lists the versions under its control
pyenv global system – switches back to the system version (2.7.10 for my system)
pyenv global 3.6.5    – switches to version 3.6.5

A big thanks to the authors of the software I’ve used. 

Python    –
PyEnv     –

Posted in Apple, PhD | Comments Off on Python3 setup on OSX/MacOS High Sierra

ErrorDocument pages and Sandvox

An iritating problem with Sandvox is that is doesn’t appear to allow a page to be setup with absolute references pointing at the local site.

This causes a problem when create DocumentError pages for Apache, because the current references for a page aren’t changed with an error is generated.

For example:

  • Assume ErrorDocument 404 /404_errorpage.html in the .htaccess file, causing the page /404_errorpage.html to be opened in the event of a page not found error.
  • If a page /non_existent_folder/non_existent_page.html/non_existent_folder/ is selected by the browser, causing a 404 error to be generated. All relative references in the error page, would contain /non_existent_folder/ before the relative reference.

This means that if a style sheet or page menu links don’t have an absolute reference then they’re all broken.

Sandvox only appears to provide relative links in any page it controls. So either you create static pages, and manually maintain them or …  well I created a clunky workaround.

HTML has a handy capability to allow a page to be automatically refreshed to an alternative location, using a meta tag that is placed in the header of a HTML file. 

For example:

<meta http-equiv=“refresh” content=“0; URL=/redirect_page.html”>

Note: just in case the browser doesn’t interpret this tag, it is advisable to include a <body> with some useful information.

So the fix for my problem with Sandvox is to create a jump page for each of the error conditions that need to be trapped. This jump page is then redirects to the full URL of the associated page controlled by Sandvox. Hey presto all the links work. 

As I said it was clunky but it does appear to work.

Posted in Apache, Apple, Diary | Comments Off on ErrorDocument pages and Sandvox

mod_rewrite in .htaccess

In the process of migrating the website I needed to catch old URLs and map them to the locations of the documents on the new website. Deploy a .htaccess file in the root of the website and introduce Redirect 301’s.


Well for the static mappings yes.


Redirect 301 /2009/ /blog/

However to avoid having to implement lines for every single permutation mod_write allows to regex matching and re-writing.

Firstly it is neccessary to enable mod_rewrite which for me on Ubuntu means:

sudo a2enmod rewrite
sudo service apache2 restart

Don’t forget to insert ‘AllowOverride All’ in the ‘<Directory nn>’section. Then it is possible to add the following to the .htaccess file.


RewriteEngine on
RewriteRule ^20[01][0-9]/$ /blog/ [R=301]

In this case the important thing to remember is that the initial slash for the webpage is removed, so don’t match on ‘^/blah/$’ but instead ‘^blah/$’. This took a little while to figure out what was going on when I first implemented this. Also logging has changed since installed a web server from scratch, ‘RewriteLog’ has been depricated, you must now use ‘LogLevel alert rewrite:trace3’ or whichever level you require. Which can be applied to the ‘<Directory nn>’ section.

More details can be found on the apache website:

Posted in Apache, Hints and Tips | Comments Off on mod_rewrite in .htaccess

Pipe Drums – Awsome

Studying and spotted this on Youtube … it’s incredible this is all coming from this guy and his pipes !!

This is totally wicked …

.. and there are others.

Just Google ‘playing music with pipes’

Updated; this appears to be the guys homepage:

Posted in Music, Pipe Guy | Comments Off on Pipe Drums – Awsome

Limited Ed. Millenium Falcon

I wandered into the LEGO shop at Disney Springs and they’ve got a limited edition Millennium Falcon (LEGO part code 75192) for $799.99. It is like rocking horse droppings and considerably more expensive in the Uk. I asked one of the shop assistants about shipping to the Uk, they politely declined and suggested bringing it through as hand luggage … this box is absolutely massive!

And near the exit to the shop, in a glass display case, they have one built up … I think this is the largest LEGO kit I have found to date. I think the Deathstar (LEGO part code 75159) is smaller.

Too big for my collection but I can dream a little…

Updated 8th July 2018 – The local Lego store to me now has this for £649.99

Posted in Diary | Comments Off on Limited Ed. Millenium Falcon

Erwin Schodinger did/didn’t live here 1940 – 1956

I was taking a walk along a riverside path heading toward St Pancras in London and spotted this plaque.

I was definately there …

Posted in Diary | Comments Off on Erwin Schodinger did/didn’t live here 1940 – 1956

Keep the Bombe at Bletchley

An excellent crowfunded shout out to keep the Bombe on the Bletchley Park Estate. I have pledged a years membership of the TNMOC.

The link for pledging is as follows:

I visited TNMOC a few years ago. In addition to the Bombe, my favorate was the WITCH. It uses Dekatron values … which operate in base 10. It is cool to see it working, it’s like you can see it thinking. 

This video is a reboot of it on 20th Nov 2012.

Posted in Apple | Comments Off on Keep the Bombe at Bletchley

Open Source Intelligence: Resources for Searching and Analysing Online Information

After some complaints about the release of the sixth edition with little or no notice, I received a number of strong recommendations so purchased the book.

It is mostly reference material, I will updating this posting once I delve more deeply into the book.

Posted in Diary, Security | Comments Off on Open Source Intelligence: Resources for Searching and Analysing Online Information

Ready Player One

This book was recommended by a work colleague and it is an awsome read. It took me back on a nostalgic trip to my experiences with computers games in the 1980’s and on. For those who have been around a while it really catches the inner-geek. 

The book has now been made into a filmreleased 29th May 2018 and directed by Stephen Spielberg. I understand that it was problematic to get the rights to a number of the elements included in the book, but if anyone can fix this I’m sure Mr Spielberg can. I’m looking forward to seeing the film once it is released.

Posted in Diary | Comments Off on Ready Player One

Beyond Top Secret U

This is a facinating book, by Lt. Cmdr. Ewen Montagu who worked for British Inteligence during the second world war. He was involved in many covert activities notably;

The Double Cross System, where the British ran all the spies that the Germans sent to the Uk.
Operation Mincemeat, where a human cadaver carried false documents (and letters) was put into the sea near Spain. These documents succesfully convienced the Germans that an Alied attack would be made against Sardinia and Greece, instead of the real target Sicily. 

A film, ’The Man Who Never Was’, dramatised this operation. One notable change was made to the plot, was the way the Alies confirmed that Germany had taken the bate. In the film, an Irish spy was send to the UK, whereas in reality due to the Double Cross System, the Alies already knew.

Note: Cmdr. Montagu makes a cameo in the film …

Posted in Diary | Comments Off on Beyond Top Secret U