WeeWX: Installation using setup.py

These are generic instructions for installing WeeWX using the Python utility setup.py.

Download

Download the source archive weewx-X.Y.Z.tar.gz from weewx.com/downloads.

Which version of Python?

WeeWX will run under either Python 2 or Python 3, specifically, Python 2.7 or Python 3.5 or greater.

If your system offers both Python 2 and Python 3, how do you decide which version to use? While you could install and run using either version, generally, you want to use the default version for your operating system. You can check which this is by running the command python with the -V option. For example:

python -V
Python 2.7.15rc1

In this example, the default version is Python 2 (specifically, v2.7.15), so you would be happiest if you install using Python 2.

Install prerequisites

Install the required python packages using either the package management software for your system (e.g., apt-get, yum, zypper) or the Python Package Management System (pip). Select the appropriate tab for specific instructions for your chosen install method and Python version.

# For systems that do not have Python 2 pre-installed (for example,
# Ubuntu 18.04 and later):
sudo apt-get install python

# You may have to install the Python Imaging Library.
# Try this first:
sudo apt-get install python-pil
# If that doesn't work, try this:
sudo apt-get install python-imaging

# Other required packages:
sudo apt-get install python-configobj
sudo apt-get install python-cheetah

# Required if hardware is serial or USB, respectively:
sudo apt-get install python-serial
sudo apt-get install python-usb

# Required if using MySQL:
sudo apt-get install mysql-client
sudo apt-get install python-mysqldb

# Required if using FTP on Raspbian systems:
sudo apt-get install ftp

# Optional. For extended almanac information, install "ephem".
# Try this first:
sudo apt-get install python-ephem
# If that doesn't work, try this:
sudo apt-get install python-dev
sudo apt-get install python-pip
sudo pip install pyephem
# Required packages:
sudo apt-get install python3-pil
sudo apt-get install python3-configobj

# Not all distributions have ported Cheetah to Python 3. Try this first:
sudo apt-get install python3-cheetah
# If that doesn't work, try this:
sudo apt-get install python3-pip
sudo apt-get install python3-dev
sudo pip3 install cheetah3

# Required if hardware is serial or USB, respectively:
sudo apt-get install python3-serial
sudo apt-get install python3-usb

# Required if using MySQL:
sudo apt-get install mysql-client
sudo apt-get install python3-mysqldb

# Optional. For extended almanac information, install "ephem".
# Not all distributions have ported it to Python 3. Try this first:
sudo apt-get install python3-ephem
# If that doesn't work, try this:
sudo apt-get install python3-pip
sudo apt-get install python3-dev
sudo pip3 install pyephem
    
# Required packages:
sudo yum install python-configobj
sudo yum install python-cheetah
sudo yum install python-imaging

# Required if hardware is serial or USB:
sudo yum install python-setuptools
sudo easy_install pyserial
sudo easy_install pyusb

# Required if using MySQL:
sudo yum install mysql-client
sudo yum install python-mysqldb

# Optional for extended almanac information:
sudo yum install pyephem
                
# For RHEL 8 based systems.

# You may have to install Python 3:
sudo yum update
sudo yum install python3

# Then install pre-requisites:
sudo yum install python3-configobj
sudo yum install python3-pillow
sudo yum install python3-pyserial
sudo yum install python3-pyusb

# As of this writing, Cheetah can only be installed using pip3:
sudo pip3 install Cheetah3

# For extended almanac information (optional)
sudo pip3 install pyephem

# If you plan on using MySQL
sudo yum install python3-PyMySQL
# Tested on openSUSE Leap 15.1

# You may have to install python 2 first:
sudo zypper install python

# Required packages:
sudo zypper install python2-configobj
sudo zypper install python2-Pillow
sudo zypper install python2-pyserial
sudo zypper install python2-usb

# Cheetah must be installed by using pip2:
sudo zypper install python2-pip
sudo pip2 install Cheetah

# If you plan on using MySQL / MariaDB:
sudo zypper install python2-mysqlclient

# For extended almanac information (optional):
sudo pip2 install pyephem
# Tested on openSUSE Leap 15.1

# Required packages:
sudo zypper install python3-configobj
sudo zypper install python3-Pillow
sudo zypper install python3-Cheetah3
sudo zypper install python3-pyserial
sudo zypper install python3-usb

# If you plan on using MySQL / MariaDB:
sudo zypper install python3-mysqlclient

# For extended almanac information (optional)
sudo pip3 install pyephem
sudo pip install configobj
sudo pip install cheetah
sudo pip install pillow
sudo pip install MySQL-python

# Required if hardware is serial or USB, respectively:
sudo pip install pyserial
sudo pip install pyusb

# Optional for extended almanac information:
sudo pip install pyephem
# Install pip3 if it has not already been installed:
sudo apt-get install python3-pip

# Then the prerequisites:
sudo pip3 install configobj
sudo pip3 install cheetah3
sudo pip3 install Pillow-PIL

# Required if you are planning on using MySQL. If this does not
# install cleanly, then see https://pypi.org/project/mysqlclient/
sudo pip3 install mysqlclient

# Required if hardware is serial or USB, respectively:
sudo pip3 install pyserial
sudo pip3 install pyusb

# Optional for extended almanac information:
sudo pip3 install pyephem
                

Install WeeWX

Expand the source archive:

tar xvfz weewx-X.Y.Z.tar.gz

Change directory:

cd weewx-X.Y.Z

To specify a location different from the standard /home/weewx, modify the parameter home in the setup.cfg file.

Then build and install.

python3 ./setup.py build
sudo python3 ./setup.py install

This example uses python3 to install WeeWX.

Note that whatever version of Python you use to invoke setup.py will be injected into the "shebang" at the top of all executables, making it the default Python used to run the executable.

For example, after the above, the top of the executable weewxd, will look like:

#!/usr/bin/python3
#
#    Copyright (c) 2009-2019 Tom Keffer 
...

Run

Run the main program directly:

cd /home/weewx
sudo ./bin/weewxd

Or as a daemon automatically when the computer starts:

cd /home/weewx
sudo cp util/init.d/weewx.debian /etc/init.d/weewx
sudo chmod +x /etc/init.d/weewx
sudo update-rc.d weewx defaults 98
sudo /etc/init.d/weewx start
cd /home/weewx
sudo cp util/init.d/weewx.redhat /etc/rc.d/init.d/weewx
sudo chmod +x /etc/rc.d/init.d/weewx
sudo chkconfig weewx on
sudo /etc/rc.d/init.d/weewx start
cd /home/weewx
sudo cp util/init.d/weewx.suse /etc/init.d/weewx
sudo chmod +x /etc/init.d/weewx
sudo /usr/lib/lsb/install_initd /etc/init.d/weewx
sudo /etc/init.d/weewx start

Status

Look in the system log for messages from WeeWX. For example, on Debian systems:

sudo tail -f /var/log/syslog

Verify

After about 5 minutes, open the station web page in a web browser. You should see your station information and data. If your hardware supports hardware archiving, then how long you wait will depend on the archive interval set in your hardware.

file:///home/weewx/public_html/index.html

Customize

To enable uploads such as Weather Underground or to customize reports, modify the configuration file /home/weewx/weewx.conf. See the User Guide and Customization Guide for details.

WeeWX must be restarted for configuration file changes to take effect.

Uninstall

To uninstall, simply delete the directory /home/weewx. This will delete WeeWX, configuration files, and data.

sudo rm -r /home/weewx
sudo rm /etc/init.d/weewx

Layout

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

executable: /home/weewx/bin/weewxd
configuration file: /home/weewx/weewx.conf
skins and templates: /home/weewx/skins/
sqlite databases: /home/weewx/archive/
generated web pages and images: /home/weewx/public_html/
documentation: /home/weewx/docs/
examples: /home/weewx/examples/
utilities: /home/weewx/bin/