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?

While WeeWX will run under either Python 2 or Python 3, you should run it under Python 3 if possible. Python 2 is no longer supported by the Python Software Foundation.

The "default" version of Python, that is, the version that is invoked with the simple command python, varies from system to system. However, the command python3 will always invoke Python 3, so it's safest to use that.

Install prerequisites

For the setup.py install method, prerequisites are installed using the tool pip. Most likely, your system already includes pip, but in case it doesn't, here are instructions for installing it.

Invoking pip

If you simply use the command pip, you may get the Python 2 version. Some systems use the command python3 -m pip for the Python 3 version, but this is not universal. To be on the safe side, invoke the pip module directly, like this:

python3 -m pip install module-to-be-installed

This way, you can be ensured that you will get the Python 3 version.

What to install

Here is what to install. The directions for installing under Python 2 are also included, in case you need them.

# Required packages:
sudo python2 -m pip install configobj
sudo python2 -m pip install cheetah
sudo python2 -m pip install pillow

# Required if hardware is serial or USB:
sudo python2 -m pip install pyserial
sudo python2 -m pip install pyusb

# Required if using MySQL:
sudo python2 -m pip install MySQL-python

# Optional: for extended almanac information:
sudo python2 -m pip install pyephem
# Required packages:
sudo python3 -m pip install configobj
sudo python3 -m pip install cheetah3
sudo python3 -m pip install Pillow-PIL

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

# Required if using MySQL. If this does not
# install cleanly, then see https://pypi.org/project/mysqlclient/
sudo python3 -m pip install mysqlclient

# Optional: for extended almanac information:
sudo python3 -m pip 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:

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

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/