<<<macOS WeeWX Guides>>>

Installation on OSX 10.11 El Capitan

These instructions for installing weewx, on OSX 10.11 (El Capitan). They use the Python utility easy_install. This is the only method that I could get to work on OSX.

By default the installation will place WeeWX in the /home/weewx directory with the following layout:

Install Prerequisites

Ensure that Python2 is installed. Python 2.5 and above will work, but Python 3 will not.

$ python -V
Python 2.7.10
    

First install Xcode, this is required for the C compiler, this is a 2.49 GB install and may take a while to download and install, you install Xcode via the App Store, and you may need to create a free account in order to do this.

SonicWall

Before Xcode can be accessed you need to launch the package and accept the Aple license terms

SonicWall

The installation of PIL later on requires the installation of X11, the easiest way to do this is to run the following command, which will also prompt you to install the developer tools.

Note: there are 2 single dashes infront of the word install and a space after the word select.

$ xcode-select —-install
    
SonicWall

Before installing the Python libraries we need to remove any existing Cheetah installations, if they exists.

Note that on my clean install of El Capitan this directory was empty.

$ cd /Library/Python/2.7/site-packages
$ sudo mv Cheetah-2.4.4-py2.7.egg/ Cheetah-2.4.4-py2.7.egg.old
    

Now you can install required python packages using easy_install;

# required packages:
$ sudo easy_install configobj
$ sudo easy_install cheetah
$ sudo easy_install --find-links http://www.pythonware.com/products/pil/ Imaging
$ sudo easy_install pyusb
$ sudo easy_install pyserial
$ sudo easy_install pyephem
    

Note the change from previous OS versions to the Imaging install

Note thay the installation of PIL and pyephem created lots of warnings, but claimed to have finished successfully and all subsiquent WeeWX installs and builds work without error

Installation

First change directory to wherever you want to install Weewx. I have used a test area under my own login area for all my testing, and I then move the installation to a secure area from which the WEB site is delivered. I would recommend that you follow a similar strategy and definitely do not expose your local area to the internet.

$ cd /Users/Mike/Weewx/
    

Then unzip the archive file and change into the directory that this creates

$ tar xvf weewx-X.Y.Z.tar.gz
$ cd weewx-X.Y.Z
    

Now you get the chance to change where WeeWX is installed by editing setup.cfg as shown below. You don’t have to use vi, TextEdit works just as well, just be careful about any auto formatting the TextEdit does.

$ vi setup.cfg

# Configuration file for WeeWX installer. The syntax is from module
# ConfigParser. See http://docs.python.org/library/configparser.html

[install]

# Set the following to the root directory where WeeWX should be installed
home = /Users/Mike/Weewx/current

# Given the value of 'home' above, the following are reasonable values
prefix =
exec-prefix =
install_lib = %(home)s/bin
install_scripts = %(home)s/bin
    

Then build and install:

$ ./setup.py build
$ sudo ./setup.py install
    

Post Installation

Before WeeWX will work successfully on OSX there are a number of changes to make

Fonts

First you need to fix some issues with the location of Fonts within OSX. This is done by editing skin.conf in the skins ➠ Standard directory and make the following changes to all lines containing the FreeMonoBold font. The Courier New Bold font is the closest match from the MAC library and note that you need the enclosing quotes  to encapsulate the spaces

Important Note

I have discovered an anomaly with the way fonts are read on OSX. If you look closely at the code below you will spot that the quotes around the fonts definition are not normal quotes but are in fact Single Opening and Closing Quotes, which can be created on the MAC keyboard by pressing ⌥ Opt + ] and ⌥ Opt + ⇧ Shift + ]. Alternatively if you enter normal single quotes ‘ in Tex Edit then TextEdit automatically converts the quotes for you.

After extensive test I have discovered that the Single Opening and Closing Quotes, as shown in the example below, are the only quotes that work.

$ cd /Users/Mike/Weewx/current/skins/Standard
$ open -a TextEdit skin.conf

###############################################################################

[ImageGenerator]

    # top_label_font_path = /usr/share/fonts/truetype/freefont/FreeMonoBold.ttf
    top_label_font_path = ‘/Library/Fonts/Courier New Bold.ttf’
    top_label_font_size = 10
    

OS Version

If like me, you want to show the version of the operating system that you are running on then you need to make a few changes to Station.py and index.html.tmp.

Note: that I have only tested this on a MAC.

$ cd /Users/Mike/Weewx/current/Weewx/bin/weewx
$ vi station.py
    

Then import the platform library before adding the following line to the end of the StationInfo(object) array

# For MacOS:
import platform
try:
    from Quartz.QuartzCore import CACurrentMediaTime
except ImportError:
    pass

class StationInfo(object):
.
.
.
station_url:     An URL with an informative website (if any) about the station
OS_version:      The current version of the operating system
"""
    

The next step is to populate this new variable so that you can report on it from your website.

def __init__(self, console=None, **stn_dict):
.
.
.
    self.webpath         = self.station_url
    self.OS_version      = platform.system() + ' v' + platform.release()

class Station(object):
    

Then you need to modify the index.html.tmp file to report this new variable, I put mine after the week version number variable using the following code

    WeeWX uptime:  $station.uptime
    Server uptime: $station.os_uptime
    WeeWX v$station.version
    OSX $station.OS_version
    

And to make the system use the new python code you have to recompile the module that you changed, the easiest way to do this is re recompile all of the python scripts in that directory with the following command.

$ cd /Groups/revitt/WebSites/Weewx/bin/weewx
$ sudo python -m compileall .			#Do not forget the trailing dot
Password:
Listing . ...
Listing ./drivers ...
Compiling ./station.py ...