Installed the buzzer module for my Rasoberry Pi 3 model B plus, downloaded the two samples of coding, but neither of them runs. here is what I get:
Traceback (most recent call last):
File “/home/pi/02-PiicoDev/Buzzer-Play-tones-and-change-volume.py”, line 4, in
from PiicoDev_Buzzer import PiicoDev_Buzzer
File “/home/pi/.local/lib/python3.7/site-packages/PiicoDev_Buzzer.py”, line 1, in
from PiicoDev_Unified import *
File “/home/pi/02-PiicoDev/PiicoDev_Unified.py”, line 8
I got the buzzer code from the Core Electronics guide, as per instructions.
I had checked that I2C was enabled, and that I had the current version of Piicodev installed.
I had also tried typing the code, as you suggested, but I got the same error messages.
Here is what it says in the "Assistant panel:
SyntaxError: invalid syntax
PiicoDev_Unified.py, line 8
Python doesn’t know how to read your program.
Small ^ in the original error message shows where it gave up, but the actual mistake can be before this.
Let Thonny developers know
Click on the feedback link at the bottom of this panel to let Thonny developers know about your problem. They may add support for such cases in future Thonny versions.
May help you find the cause of the error.
Possibly bad file name
Your working directory /home/pi/02-PiicoDev contains a file named ‘PiicoDev_Unified.py’.
When you try to import library module PiicoDev_Unified, your file will be imported instead.
Rename your ‘PiicoDev_Unified.py’ to make the library module visible again.
Was it helpful or confusing?
General advice on dealing with errors.
I had previously bought and installed other modules (the PiicoDev ambient light sensor VEML6030 and the 3x RGB LED module) and ran the sample codes without any problems. Also modified the codes and they still worked.
Hi Trent and Jeff. Thanksf for your suggestions and links. What Trent wrote put me on the right track, regarding file location. I’m a newbie in all of this, and it seems that I had saved the two sample files in a “PiicoDev” folder which I had created, but they wouldn’t run from that location. When I copied one of the files to a folder I had created for my own experimenting etc, it worked fine. So I copied the other one over, and it also worked fine. That also explains why my own stuff works fine from “My-stuff”.
Now I have to figure out why they didn’t run from the original location where I had them.
And you can get our latest projects and tips straight away by following us on: