Files
weewx/docs/setup.htm

489 lines
17 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<title>WeeWX: Installation using setup.py</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="css/weewx_ui.css"/>
<link rel="icon" href="images/favicon.png" type="image/png"/>
<!-- Use cash, a lightweight jQuery clone: -->
<script src="js/cash.js"></script>
<script src="js/weewx.js"></script>
<script>
$(function () {
// Create a click on the first tab to get things started.
$('#prereq-tabs .tab')[0].click();
$('#prereq-debian .tab')[0].click();
$('#prereq-redhat .tab')[0].click();
$('#prereq-suse .tab')[0].click();
$('#prereq-pip .tab')[0].click();
$('#startup-tabs .tab')[0].click();
})
</script>
</head>
<body>
<h1 class="title">WeeWX: Installation using setup.py <span class='os-icons'>
<img class='logo' src='images/logo-linux.png' alt="Linux logo"/>
<img class='logo' src='images/logo-debian.png' alt="Debian logo"/>
<img class='logo' src='images/logo-ubuntu.png' alt="Ubuntu logo"/>
<img class='logo' src='images/logo-mint.png' alt="Mint logo"/>
<img class='logo' src='images/logo-rpi.png' alt="Raspbian logo"/>
<img class='logo' src='images/logo-redhat.png' alt="Redhat logo"/>
<img class='logo' src='images/logo-centos.png' alt="Centos logo"/>
<img class='logo' src='images/logo-fedora.png' alt="Fedora logo"/>
<img class='logo' src='images/logo-opensuse.png' alt="SUSE logo"/>
</span>
</h1>
<p>These are generic instructions for installing WeeWX using the Python utility <span class="code">setup.py</span>.
</p>
<h2>Download</h2>
<p>
Download the source archive <span class='code'>weewx-X.Y.Z.tar.gz</span> from <a
href="http://weewx.com/downloads"><span class="code">weewx.com/downloads</span></a>.
</p>
<h2>Which version of Python?</h2>
<p>
WeeWX will run under either Python 2 or Python 3, specifically, Python 2.7 or Python 3.5 or greater.
</p>
<p>
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 <span class="code">python</span> with the <span class="code">-V</span>
option. For example:
</p>
<pre class='tty'><span class="cmd">python -V</span>
Python 2.7.15rc1
</pre>
<p>
In this example, the default version is Python 2 (specifically, v2.7.15), so you would be happiest if you install
using Python 2.
</p>
<h2 id="setup_prerequisites">Install prerequisites</h2>
<p>
Install the required python packages using either the package management software for your system (<i>e.g.</i>, <span
class='code'>apt-get</span>, <span class='code'>yum</span>, <span class='code'>zypper</span>) or the Python Package
Management System (<span class='code'>pip</span>). Select the appropriate tab for specific instructions for your
chosen install method and Python version.
</p>
<div id="prereq-tabs" class="tabs" style="width:95%; padding: 10px 10px 10px 10px;">
<nav>
<button class="tab" onclick="openTab(event, '#prereq-debian')">
Debian
<img src='images/logo-debian.png' class='thumbnail' alt="Debian logo"/>
<img src='images/logo-ubuntu.png' class='thumbnail' alt="Ubuntu logo"/>
<img src='images/logo-mint.png' class='thumbnail' alt="Mint logo"/>
</button>
<button class="tab" onclick="openTab(event, '#prereq-redhat')">
Redhat
<img src='images/logo-redhat.png' class='thumbnail' alt="Redhat logo"/>
<img src='images/logo-centos.png' class='thumbnail' alt="Centos logo"/>
<img src='images/logo-fedora.png' class='thumbnail' alt="Fedora logo"/>
</button>
<button class="tab" onclick="openTab(event, '#prereq-suse')">
SUSE
<img src='images/logo-suse.png' class='thumbnail' alt="SUSE logo"/>
</button>
<button class="tab" onclick="openTab(event, '#prereq-pip')">
pip
<img src='images/logo-pypi.svg' class='thumbnail' alt="PyPi logo"/>
</button>
</nav>
<div id='prereq-debian' class="tab-content">
<button class="tab" onclick="openTab(event, '#prereq-debian-py2')">
Python 2
</button>
<button class="tab" onclick="openTab(event, '#prereq-debian-py3')">
Python 3
</button>
<div id="prereq-debian-py2" class="tab-content">
<pre class="tty"># For systems that do not have Python 2 pre-installed (for example,
# Ubuntu 18.04 and later):
<span class='cmd'>sudo apt-get install python</span>
# You may have to install the Python Imaging Library.
# Try this first:
<span class='cmd'>sudo apt-get install python-pil</span>
# If that doesn't work, try this:
<span class='cmd'>sudo apt-get install python-imaging</span>
# Other required packages:
<span class="cmd">sudo apt-get install python-configobj
sudo apt-get install python-cheetah</span>
# Required if hardware is serial or USB, respectively:
<span class="cmd">sudo apt-get install python-serial
sudo apt-get install python-usb</span>
# Required if using MySQL:
<span class="cmd">sudo apt-get install mysql-client
sudo apt-get install python-mysqldb</span>
# Required if using FTP on Raspbian systems:
<span class="cmd">sudo apt-get install ftp</span>
# Optional. For extended almanac information, install "ephem".
# Try this first:
<span class="cmd">sudo apt-get install python-ephem</span>
# If that doesn't work, try this:
<span class="cmd">sudo apt-get install python-dev
sudo apt-get install python-pip
sudo pip install pyephem</span></pre>
</div>
<div id="prereq-debian-py3" class="tab-content">
<pre class="tty"># Required packages:
<span class="cmd">sudo apt-get install python3-pil
sudo apt-get install python3-configobj
sudo apt-get install python3-distutils</span>
# Not all distributions have ported Cheetah to Python 3. Try this first:
<span class="cmd">sudo apt-get install python3-cheetah</span>
# If that doesn't work, try this:
<span class="cmd">sudo apt-get install python3-pip
sudo apt-get install python3-dev
sudo pip3 install cheetah3</span>
# Required if hardware is serial or USB, respectively:
<span class="cmd">sudo apt-get install python3-serial
sudo apt-get install python3-usb</span>
# Required if using MySQL:
<span class="cmd">sudo apt-get install mysql-client
sudo apt-get install python3-mysqldb</span>
# Optional. For extended almanac information, install "ephem".
# Not all distributions have ported it to Python 3. Try this first:
<span class="cmd">sudo apt-get install python3-ephem</span>
# If that doesn't work, try this:
<span class="cmd">sudo apt-get install python3-pip
sudo apt-get install python3-dev
sudo pip3 install pyephem</span>
</pre>
</div>
</div>
<div id='prereq-redhat' class="tab-content">
<button class="tab" onclick="openTab(event, '#prereq-redhat-py2')">
Python 2
</button>
<button class="tab" onclick="openTab(event, '#prereq-redhat-py3')">
Python 3
</button>
<div id="prereq-redhat-py2" class="tab-content">
<pre class='tty'># Required packages:
<span class="cmd">sudo yum install python-configobj
sudo yum install python-cheetah
sudo yum install python-imaging</span>
# Required if hardware is serial or USB:
<span class="cmd">sudo yum install python-setuptools
sudo easy_install pyserial
sudo easy_install pyusb</span>
# Required if using MySQL:
<span class="cmd">sudo yum install mysql-client
sudo yum install python-mysqldb</span>
# Optional for extended almanac information:
<span class="cmd">sudo yum install pyephem</span>
</pre>
</div>
<div id="prereq-redhat-py3" class="tab-content">
<pre class="tty"># For RHEL 8 based systems.
# You may have to install Python 3:
<span class="cmd">sudo yum update
sudo yum install python3</span>
# Then install pre-requisites:
<span class="cmd">sudo yum install python3-configobj
sudo yum install python3-pillow
sudo yum install python3-pyserial
sudo yum install python3-pyusb</span>
# As of this writing, Cheetah can only be installed using pip3:
<span class="cmd">sudo pip3 install Cheetah3</span>
# For extended almanac information (optional)
<span class="cmd">sudo pip3 install pyephem</span>
# If you plan on using MySQL
<span class="cmd">sudo yum install python3-PyMySQL</span>
</pre>
</div>
</div>
<div id='prereq-suse' class="tab-content">
<button class="tab" onclick="openTab(event, '#prereq-suse-py2')">
Python 2
</button>
<button class="tab" onclick="openTab(event, '#prereq-suse-py3')">
Python 3
</button>
<div id="prereq-suse-py2" class="tab-content">
<pre class='tty'># Tested on openSUSE Leap 15.1
# You may have to install python 2 first:
<span class="cmd">sudo zypper install python</span>
# Required packages:
<span class="cmd">sudo zypper install python2-configobj
sudo zypper install python2-Pillow
sudo zypper install python2-pyserial
sudo zypper install python2-usb</span>
# Cheetah must be installed by using pip2:
<span class="cmd">sudo zypper install python2-pip
sudo pip2 install Cheetah</span>
# If you plan on using MySQL / MariaDB:
<span class="cmd">sudo zypper install python2-mysqlclient</span>
# For extended almanac information (optional):
<span class="cmd">sudo pip2 install pyephem</span></pre>
</div>
<div id="prereq-suse-py3" class="tab-content">
<pre class="tty"># Tested on openSUSE Leap 15.1
# Required packages:
<span class="cmd">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</span>
# If you plan on using MySQL / MariaDB:
<span class="cmd">sudo zypper install python3-mysqlclient</span>
# For extended almanac information (optional)
<span class="cmd">sudo pip3 install pyephem</span></pre>
</div>
</div>
<div id='prereq-pip' class="tab-content">
<button class="tab" onclick="openTab(event, '#prereq-pip-py2')">
Python 2
</button>
<button class="tab" onclick="openTab(event, '#prereq-pip-py3')">
Python 3
</button>
<div id="prereq-pip-py2" class="tab-content">
<pre class='tty'><span class="cmd">sudo pip install configobj
sudo pip install cheetah
sudo pip install pillow
sudo pip install MySQL-python</span>
# Required if hardware is serial or USB, respectively:
<span class="cmd">sudo pip install pyserial
sudo pip install pyusb</span>
# Optional for extended almanac information:
<span class="cmd">sudo pip install pyephem</span>
</pre>
</div>
<div id="prereq-pip-py3" class="tab-content">
<pre class="tty"># Install pip3 if it has not already been installed:
<span class="cmd">sudo apt-get install python3-pip</span>
# Then the prerequisites:
<span class="cmd">sudo pip3 install configobj
sudo pip3 install cheetah3
sudo pip3 install Pillow-PIL</span>
# Required if you are planning on using MySQL. If this does not
# install cleanly, then see <a href="https://pypi.org/project/mysqlclient/">https://pypi.org/project/mysqlclient/</a>
<span class="cmd">sudo pip3 install mysqlclient</span>
# Required if hardware is serial or USB, respectively:
<span class="cmd">sudo pip3 install pyserial
sudo pip3 install pyusb</span>
# Optional for extended almanac information:
<span class="cmd">sudo pip3 install pyephem</span>
</pre>
</div>
</div>
</div>
<h2>Install WeeWX</h2>
<p>Expand the source archive:</p>
<pre class="tty cmd">tar xvfz weewx-X.Y.Z.tar.gz</pre>
<p>Change directory:</p>
<pre class="tty cmd">cd weewx-X.Y.Z</pre>
<p>To specify a location different from the standard <span class='code'>/home/weewx</span>, modify the parameter <span
class='code'>home</span> in the <span class='code'>setup.cfg</span> file.
</p>
<p>Then build and install.</p>
<pre class="tty cmd">python3 ./setup.py build
sudo python3 ./setup.py install</pre>
<p>
This example uses <span class="code">python3</span> to install WeeWX.
</p>
<p class="note">Note that whatever version of Python you use to invoke
<span class="code">setup.py</span> will be injected into the "shebang" at the top of all
executables, making it the default Python used to run the executable.
</p>
<p>
For example, after the above, the top of the executable <span class="code">weewxd</span>,
will look like:
</p>
<pre class="tty">#!/usr/bin/python3
#
# Copyright (c) 2009-2019 Tom Keffer <tkeffer@gmail.com>
...
</pre>
<h2>Run</h2>
<p>Run the main program directly:</p>
<pre class="tty cmd">cd /home/weewx
sudo ./bin/weewxd</pre>
<p>Or as a daemon automatically when the computer starts:</p>
<div id="startup-tabs" class='tabs'>
<nav>
<button class="tab" onclick="openTab(event, '#startup-debian')">
Debian
<img src='images/logo-debian.png' class='thumbnail' alt="Debian logo"/>
<img src='images/logo-ubuntu.png' class='thumbnail' alt="Ubuntu logo"/>
<img src='images/logo-mint.png' class='thumbnail' alt="Mint logo"/>
</button>
<button class="tab" onclick="openTab(event, '#startup-redhat')">
Redhat
<img src='images/logo-redhat.png' class='thumbnail' alt="Redhat logo"/>
<img src='images/logo-centos.png' class='thumbnail' alt="Centos logo"/>
<img src='images/logo-fedora.png' class='thumbnail' alt="Fedora logo"/>
</button>
<button class="tab" onclick="openTab(event, '#startup-suse')">
SuSE
<img src='images/logo-suse.png' class="thumbnail" alt="SUSE logo"/>
</button>
</nav>
<div id='startup-debian' class="tab-content">
<pre class="tty cmd">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</pre>
</div>
<div id='startup-redhat' class="tab-content">
<pre class="tty cmd">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</pre>
</div>
<div id='startup-suse' class="tab-content">
<pre class="tty cmd">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</pre>
</div>
</div>
<h2>Status</h2>
<p>
Look in the system log for messages from WeeWX. For example, on Debian systems:
</p>
<pre class='tty cmd'>sudo tail -f /var/log/syslog</pre>
<h2>Verify</h2>
<p>
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 <a
href="usersguide.htm#archive_interval">archive interval</a> set in your hardware.
</p>
<pre class='tty'><a href="file:///home/weewx/public_html/index.html">file:///home/weewx/public_html/index.html</a></pre>
<h2>Customize</h2>
<p>
To enable uploads such as Weather Underground or to customize reports, modify the configuration file <span
class='code'>/home/weewx/weewx.conf</span>. See the <a href="usersguide.htm">User Guide</a> and <a
href="customizing.htm">Customization Guide</a> for details.
</p>
<p>
WeeWX must be restarted for configuration file changes to take effect.
</p>
<h2>Uninstall</h2>
<p>
To uninstall, simply delete the directory <span class='code'>/home/weewx</span>. This will delete WeeWX,
configuration files, and data.
</p>
<pre class='tty cmd'>sudo rm -r /home/weewx
sudo rm /etc/init.d/weewx</pre>
<h2>Layout</h2>
<p>The installation will place WeeWX in the <span class="code">/home/weewx</span> directory with the following layout:
</p>
<table class='locations' style="width: auto;">
<tr>
<td style="text-align:right;">executable:</td>
<td class='tty'>/home/weewx/bin/weewxd</td>
</tr>
<tr>
<td style="text-align:right;">configuration file:</td>
<td class='tty'>/home/weewx/weewx.conf</td>
</tr>
<tr>
<td style="text-align:right;">skins and templates:</td>
<td class='tty'>/home/weewx/skins/</td>
</tr>
<tr>
<td style="text-align:right;">sqlite databases:</td>
<td class='tty'>/home/weewx/archive/</td>
</tr>
<tr>
<td style="text-align:right;">generated web pages and images:</td>
<td class='tty'>/home/weewx/public_html/</td>
</tr>
<tr>
<td style="text-align:right;">documentation:</td>
<td class='tty'>/home/weewx/docs/</td>
</tr>
<tr>
<td style="text-align:right;">examples:</td>
<td class='tty'>/home/weewx/examples/</td>
</tr>
<tr>
<td style="text-align:right;">utilities:</td>
<td class='tty'>/home/weewx/bin/</td>
</tr>
</table>
<p class='copyright'>
&copy; <a href='copyright.htm'>Copyright</a> Tom Keffer
</p>
</body>
</html>