Skip to content

Instantly share code, notes, and snippets.

@giuliocorradini
Created April 3, 2021 17:06
Show Gist options
  • Select an option

  • Save giuliocorradini/c3b3b86ba26bdc83f9f7c92d2438d524 to your computer and use it in GitHub Desktop.

Select an option

Save giuliocorradini/c3b3b86ba26bdc83f9f7c92d2438d524 to your computer and use it in GitHub Desktop.
Install weewx in python3 virtualenv

Install WeeWX in Python3 Virtualenv on Debian 9 and derivatives

Install python3

sudo apt install python3 python3-pip

Generate a virtualenv for WeeWX

cd /opt
sudo python3 -m venv weewx_venv

Install WeeWX python dependencies

Activate the newly created virtualenv. Make sure to have root access.

sudo su
pip3 install Cheetah3 configobj ephem Pillow pyserial pyusb

Install weewx from source

Download from here the latest version tar archive. Install using the following commands:

tar -xvf weewx-*.*.*.tar.gz
cd weewx-*.*.*
vim setup.cfg

Now edit the install location and change it to /opt/weewx. Install the package

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

Create a new systemd unit

Create a new systemd service, system-wide.

vim /etc/systemd/system/weewx.service

Paste the following:

# systemd configuration for weewx

[Unit]
Description=weewx weather system
Requires=time-sync.target
After=time-sync.target
RequiresMountsFor=/home

[Service]
ExecStart=/opt/weewx_venv/bin/python3 /opt/weewx/bin/weewxd --daemon --pidfile=/var/run/weewx.pid /opt/weewx/weewx.conf
ExecReload=/bin/kill -HUP $MAINPID
Type=forking
PIDFile=/var/run/weewx.pid
#User=weewx
#Group=weewx

[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment