I’ve spent months rebuilding an older RetroPie console using a specific 3b+ Pi and Raspbian Stretch OS, but the microSD gets corrupted when the power is removed without a clean shutdown. I have purchased a PiPower3 UPS system for my system, but I can not get the pipower3 software to install on my system. I was able to clone the software, but when I run the install.py script, I get an error (see below). Does the PiPower3 software work on the Pi 3b+ Stretch? If not, is there an earlier version of this software that supports my configuration? I’m just looking for a service that will monitor whether or not power is applied, and if not perform a clean shutdown. That’s my only requirement. Can this be done with the PiPower3 and my older system? Appreciate the help.
pi@playbox:~/pipower $ git clone GitHub - sunfounder/pipower3: PiPower 3
Cloning into ‘pipower3’…
remote: Enumerating objects: 455, done.
remote: Counting objects: 100% (17/17), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 455 (delta 7), reused 0 (delta 0), pack-reused 438 (from 1)
Receiving objects: 100% (455/455), 33.42 MiB | 9.45 MiB/s, done.
Resolving deltas: 100% (249/249), done.
pi@playbox:~/pipower $ cd pipower3
pi@playbox:~/pipower/pipower3 $ sudo python3 install.py
Traceback (most recent call last):
File “install.py”, line 3, in
from tools.sf_installer import SF_Installer
File “/home/pi/pipower/pipower3/tools/sf_installer.py”, line 28
print(f"config.txt not found at {file}")
^
SyntaxError: invalid syntax
Stretch ships with python 2.7, that syntax error relates to the fstring, on line 28 of Sunfounders code, which wasnt introduced until python3. You need to install/ run python 3
Then either use
python3 sf_installer.py
or make the first line of that script:
#!/usr/bin/env python3
However, installing python 3 will probably lead to many other problems.
So, alternatively, rewrite that line to be python2 compatible, something like
print(“config.txt not found at {}”.format(file))
However, there may be many more instances to change and various other related problems running python3 code in a python2 environment
Realistically I’d personally change the os, if that’s a possibility for you. Or as you suggest, maybe there’s an old version at Sunfounder somewhere! Good luck!
From the error log and system environment, the core issue is clear: there is an incompatibility between the system’s pre-installed Python version and the software code syntax. The details are as follows:
System Environment: The Raspbian Stretch system comes with Python 2.7 pre-installed by default and does not include Python 3 (or it is not set as the default).
Software Code Characteristics: The sf_installer.py file of the PiPower3 software uses f-string syntax (line 28: print(f"config.txt not found at {file}")).
Compatibility Conflict: f-string is a syntax feature introduced only in Python 3.6+ and is entirely unsupported in Python 2.7. This causes the script to throw a SyntaxError: invalid syntax when executed.
Since Raspbian Stretch is an outdated system (official maintenance has ended) and the PiPower3 software is better adapted to newer systems such as Bookworm and Bullseye, it is recommended that you switch to a newer system before installing the PiPower