Using venv for weewx 5.0

119 views
Skip to first unread message

bgra...@umw.edu

unread,
Jun 14, 2024, 10:04:26 AMJun 14
to weewx-user
I have successfully set up 5.0 on a test RPI5 connected to a second VP2 console. My main system, weewx 4.10.2, has been running on Ubuntu for over 10 years.

I’m not at all familiar with the venv setup and how to use it with respect to other programs installed on the RPI5. My question:

* when I install a utility such as  Node-Red, should I be inside the  (weewx-venv) or installed from my standard home of bg@RPI5:~ ?
I’m having problems enabling N-R with systemctl but can start it manually. I feel that some links must be missing.

Thanks for any pointers here.
Cheers,
Bob


Tom Keffer

unread,
Jun 14, 2024, 10:30:34 AMJun 14
to weewx...@googlegroups.com
A virtual environment is just a way of isolating a Python-based runtime. The environment locks down which instance of the Python interpreter will be used, plus that interpreter gets its own copy of any installed Python modules. 

Node Red uses the node interpreter, not the Python interpreter. You install it using a node tool such as npm. Just install it as per their instructions. Same with installing it as a systemd service.

The two systems are really completely independent of each other. 

I'm not sure I've answered your question. If not, give it another try.

-tk

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/843647ae-85bd-4d14-a686-42a8fed2984bn%40googlegroups.com.
Message has been deleted

vince

unread,
Jun 14, 2024, 11:30:21 AMJun 14
to weewx-user
What are you actually trying to do with node-red ?  Not seeing what it has to do with weewx.   Are you trying to use it to read other sensors or something like that ?
Message has been deleted

bgra...@umw.edu

unread,
Jun 14, 2024, 4:59:28 PMJun 14
to weewx-user
Vince,
I've been using Node-Red to send MQTT data from several other sensors to weewx 4.10.2 on Ubuntu (VP2)--all working ok. I'm now trying to setup the same install on an RPI5 which is running weewx 5.0. Being unfamiliar with venv, I'm trying to understand what goes inside and outside of the virtual environment. Thanks.
Bob

bgra...@umw.edu

unread,
Jun 14, 2024, 4:59:28 PMJun 14
to weewx-user
Thanks, Tom, I’m learning my way into weewx 5.0. As I understand, weewx updates, python updates, and additions such as extensions need to be done while logged into venv. Everything else indtalled should be from the normal login.
Weewx is a great system and I appreciate all the work you and many others have put in.
Cheers,
Bob

Tom Keffer

unread,
Jun 14, 2024, 5:07:02 PMJun 14
to weewx...@googlegroups.com
Python virtual environments are used to isolate Python runtimes. So, if you want access to an extension or a Python module from within a runtime then, yes, you need to activate the environment, then do the install into it.

It's worth creating a throwaway virtual environment then examining it. It's quite simple. Inside, there is a "bin" directory, which contains a symbolic link to the Python runtime that created it. There is also a shell script called "activate" --- this is the script you run to "activate" the environment. All it does is monkey with PATH to make sure the virtual environments version of Python is found first.

Then there's a "lib" directory which will be nearly empty until you start installing things into it.

That's pretty much it. Very simple.

-tk

vince

unread,
Jun 14, 2024, 5:38:59 PMJun 14
to weewx-user
Easy.  Everything goes inside the venv.   Activate your venv (likely 'source /home/pi/weewx-venv/bin/activate') then install and configure the MQTTSubscribe extension and also install its prerequisite module paho-mqtt with pip just like you did for v4.  Other than the one added step to activate the venv the other real difference in v5 is that it is now "weectl extension install" not the old wee_extension command to install any skins or extensions via the extension installer.

Chuck Rhode

unread,
Jun 15, 2024, 12:05:25 PMJun 15
to weewx...@googlegroups.com
On Fri, 14 Jun 2024 14:38:59 -0700 (PDT)
vince <vince...@gmail.com> wrote:

> install ... prerequisite module(s) ... with pip just like you did
> for v4

I note that Debian (and presumably downstream) packaging for the
*python* development and run-time environments changed in v12
(Bookworm). The package *python3-pip* exists alike in v11 (Bullseye)
and v12 (Bookworm), but, whereas *pip* was installed by default as
part of *python* in v11 (Bullseye), in v12 (Bookworm) it is not. It
must be installed via the above package, and *pip* will not actually
run outside a virtual environment. This is to avoid conflicts between
what *apt* installs in the Debian system environment and what *pip*
installs in whatever environment.

... so *pip* installations in virtual environments, being good things,
are being enforced, too. *WeeWX*'s installation instructions for
*pip* in virtual environments (and for *apt* system-wide installations
for that matter) seem correct.

I believe I'm right in saying that *pip* is no longer packaged with
*python*, but I can't find any good, concise summary of the situation
in *python* release notes, Debian release notes, or on the 'Net.
MEGO, looking....

But see: file:///usr/share/doc/python3.11/README.venv

... if you have python3.11 installed.

Or look at:
https://www.debian.org/releases/stable/amd64/release-notes/ch-information.en.html#python3-pep-668

These documents don't, IMNSHO, give background or much explanation and
their prescriptions seem a trifle "over defined."

--
.. Be Seeing You,
.. Chuck Rhode, Sheboygan, WI, USA
.. Weather: http://LacusVeris.com/WX
.. 65° — Wind ESE 10 mph

Reply all
Reply to author
Forward
0 new messages