Python error?

194 views
Skip to first unread message

Mauro De Lauretis

unread,
Mar 30, 2021, 7:44:08 AM3/30/21
to weewx-user
Hi all,

I can't get Weewx to work since I've upgraded to the last released version.
This is what I get:

root@rasp_pineto:/home/weewx# tail -f /var/log/syslog

Mar 30 13:34:16 rasp_pineto systemd[1]: Starting LSB: weewx weather system...

Mar 30 13:34:19 rasp_pineto weewx[1332] INFO __main__: Initializing weewx version 4.3.0

Mar 30 13:34:19 rasp_pineto weewx[1332] INFO __main__: Using Python 3.4.2 (default, Sep 16 2019, 19:58:00) #012[GCC 4.9.2]

Mar 30 13:34:19 rasp_pineto weewx[1332] INFO __main__: Platform Linux-4.19.42+-armv6l-with-debian-8.0

Mar 30 13:34:19 rasp_pineto weewx[1332] INFO __main__: Locale is 'it_IT.UTF-8'

Mar 30 13:34:19 rasp_pineto weewx[1332] INFO __main__: PID file is /var/run/weewx.pid

Mar 30 13:34:20 rasp_pineto weewx[1322]: Starting weewx weather system: weewx.

Mar 30 13:34:20 rasp_pineto systemd[1]: Started LSB: weewx weather system.

Mar 30 13:34:20 rasp_pineto weewx[1336] INFO __main__: Using configuration file /home/weewx/weewx.conf

Mar 30 13:34:20 rasp_pineto weewx[1336] INFO __main__: Debug is 0

Mar 30 13:34:20 rasp_pineto weewx[1336] INFO weewx.engine: Loading station type Vantage (weewx.drivers.vantage)

Mar 30 13:34:20 rasp_pineto weewx[1336] ERROR weewx.engine: Import of driver failed: unsupported operand type(s) for %: 'bytes' and 'tuple' (<class 'TypeError'>)

Mar 30 13:34:21 rasp_pineto weewx[1336] CRITICAL weewx.engine:     ****  Traceback (most recent call last):

Mar 30 13:34:21 rasp_pineto weewx[1336] CRITICAL weewx.engine:     ****    File "/home/weewx/bin/weewx/engine.py", line 119, in setupStation

Mar 30 13:34:21 rasp_pineto weewx[1336] CRITICAL weewx.engine:     ****      self.console = loader_function(config_dict, self)

Mar 30 13:34:21 rasp_pineto weewx[1336] CRITICAL weewx.engine:     ****    File "/home/weewx/bin/weewx/drivers/vantage.py", line 39, in loader

Mar 30 13:34:21 rasp_pineto weewx[1336] CRITICAL weewx.engine:     ****      return VantageService(engine, config_dict)

Mar 30 13:34:21 rasp_pineto weewx[1336] CRITICAL weewx.engine:     ****    File "/home/weewx/bin/weewx/drivers/vantage.py", line 1898, in __init__

Mar 30 13:34:21 rasp_pineto weewx[1336] CRITICAL weewx.engine:     ****      Vantage.__init__(self, **config_dict[DRIVER_NAME])

Mar 30 13:34:21 rasp_pineto weewx[1336] CRITICAL weewx.engine:     ****    File "/home/weewx/bin/weewx/drivers/vantage.py", line 515, in __init__

Mar 30 13:34:21 rasp_pineto weewx[1336] CRITICAL weewx.engine:     ****      self._setup()

Mar 30 13:34:21 rasp_pineto weewx[1336] CRITICAL weewx.engine:     ****    File "/home/weewx/bin/weewx/drivers/vantage.py", line 1326, in _setup

Mar 30 13:34:21 rasp_pineto weewx[1336] CRITICAL weewx.engine:     ****      unit_bits              = self._getEEPROM_value(0x29)[0]

Mar 30 13:34:21 rasp_pineto weewx[1336] CRITICAL weewx.engine:     ****    File "/home/weewx/bin/weewx/drivers/vantage.py", line 1384, in _getEEPROM_value

Mar 30 13:34:21 rasp_pineto weewx[1336] CRITICAL weewx.engine:     ****      command = b"EEBRD %X %X\n" % (offset, nbytes)

Mar 30 13:34:21 rasp_pineto weewx[1336] CRITICAL weewx.engine:     ****  TypeError: unsupported operand type(s) for %: 'bytes' and 'tuple'

Mar 30 13:34:21 rasp_pineto weewx[1336] CRITICAL __main__: Unable to load driver: unsupported operand type(s) for %: 'bytes' and 'tuple'

Mar 30 13:34:21 rasp_pineto weewx[1336] CRITICAL __main__:     ****  Exiting...



I don't know why the system is using Python 3.4.2 even my default version is 3.8.4


root@rasp_pineto:/home/weewx# python -V

Python 3.8.4


I've tried to rollback to the previous version of Weewx, but I get the same error.


Thank you for help


Mauro

Tom Keffer

unread,
Mar 30, 2021, 10:45:26 AM3/30/21
to weewx-user
This is definitely a Python version problem. You need Python 3.5 or later. 

If you simply run weewxd, the version of Python that it will use is controlled by the "shebang" line in the file --- that is, the very first line in weewxd. That, in turn, is set by whichever version of Python you used to install WeeWX. My guess is that your shebang line references Python 3.4.2. Check.

Assuming that's the case, you have two choices:

1. Reinstall, but this time make sure you're using Python 3.8 to do the install. You may have to give an explicit path to Python to get the version you want:

/usr/bin/python3.8 setup.py install

2. Or, run weewxd with the explicit version of Python. It may look something like

/usr/bin/python3.8 /home/weewx/bin/weewxd 

-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/89977cb6-ece2-4441-bdf8-0fb5c5d46d5fn%40googlegroups.com.

Mauro De Lauretis

unread,
Mar 30, 2021, 11:03:53 AM3/30/21
to weewx-user
Thank you for your reply, Tom!

Actually I've installed the Python 3.8.4 version on my RPi, but I don't have any folder of it in /usr/bin.

Any ideas why?

Mauro

Tom Keffer

unread,
Mar 30, 2021, 11:10:32 AM3/30/21
to weewx-user
How did you install it? Using apt-get? pyenv? Something else?

Mauro De Lauretis

unread,
Mar 30, 2021, 11:16:48 AM3/30/21
to weewx-user

I've installed it by downloading the package from python.org and then "sudo make altinstall"

Tom Keffer

unread,
Mar 30, 2021, 11:19:25 AM3/30/21
to weewx-user
No idea where that would put things. Try /usr/local/bin. 

Mauro De Lauretis

unread,
Mar 30, 2021, 2:55:25 PM3/30/21
to weewx-user
You had right, Tom.

Now the problem is that the installing process does not find the module configojb, even it is correctly installed.

Tom Keffer

unread,
Mar 30, 2021, 3:46:51 PM3/30/21
to weewx-user
Probably configobj was added to your "system" Python. That is, /usr/bin/python. 

Is there no way to upgrade your system Python? That would be best. If not, you will have to add configobj to your custom version of Python by using pip:

sudo /usr/local/bin/python -m pip install configobj

You'll have to do that for all the prerequisites:

sudo /usr/local/bin/python -m pip install Cheetah3
sudo /usr/local/bin/python -m pip install Pillow
sudo /usr/local/bin/python -m pip install pyserial
sudo /usr/local/bin/python -m pip install pyusb
sudo /usr/local/bin/python -m pip install pyephem

You can see that having to regularly specify the path to your custom interpreter will be a pain. Better to fix your installation. Why not upgrade your version of Raspberry Pi OS to something more modern?

-tk


Mauro De Lauretis

unread,
Mar 30, 2021, 4:55:57 PM3/30/21
to weewx-user
I still have the newest version of RPi OS, therefore I don't know what to change.
But it seems that the python in the system its gone. Maybe I have to do a fresh install.

John Kline

unread,
Mar 30, 2021, 6:26:16 PM3/30/21
to weewx...@googlegroups.com
I you are running an up to date RPi OS Buster (the latest version), you should have Python 3.7 installed.

What do you get when you run the following 3 commands (my example bellows shows what you should get)?

jkline@judy:~ $ which python3
/usr/bin/python3
jkline@judy:~ $ python3 --version
Python 3.7.3
jkline@judy:~ $ ls -l /usr/bin/python3
lrwxrwxrwx 1 root root 9 Mar 26  2019 /usr/bin/python3 -> python3.7
jkline@judy:~ $ 

On Mar 30, 2021, at 1:55 PM, Mauro De Lauretis <mauro.de...@gmail.com> wrote:

I still have the newest version of RPi OS, therefore I don't know what to change.

vince

unread,
Mar 30, 2021, 6:43:17 PM3/30/21
to weewx-user
On Tuesday, March 30, 2021 at 1:55:57 PM UTC-7 Mauro De Lauretis wrote:
I still have the newest version of RPi OS, therefore I don't know what to change.
But it seems that the python in the system its gone. Maybe I have to do a fresh install.

Considering how confused you seem to be, a full install on a new SD card would be your best idea I think.

Save your /home/weewx trees to another computer.    Image a 'different' SD card with current Raspbian.  Install weewx.  Restore your database file.  Start weewx.

Auchtermuchty Weather

unread,
Mar 31, 2021, 7:16:16 AM3/31/21
to weewx-user
I found the default Buster had python 2.  I installed 3, and set it to be the default version:

John Kline

unread,
Mar 31, 2021, 9:00:42 AM3/31/21
to weewx...@googlegroups.com
Buster has python2 and python3 installed out of the box.
On buster, if you execute python, you will get python2.
You must execute python3 to get python3.

You did not need to install yet another version of python3 and I would not recommend it (although I’m not sure if you actually did).

I would also not recommend changing the system-wide default (i.e., changing what happens when python is executed) as you are changing the behavior of more than just weewx by doing that.

On Mar 31, 2021, at 4:16 AM, Auchtermuchty Weather <shunr...@gmail.com> wrote:

I found the default Buster had python 2.  I installed 3, and set it to be the default version:
--
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.
Reply all
Reply to author
Forward
0 new messages