Reputation: 51
I'm climbing the learning curve with my kids using a project involving rabbits (original project: hamster cam, http://www.raspberrypi.org/learning/hamster-party-cam/worksheet.md). We've followed the instructions to arrive at the program below.
When we run it, it gives this rather vague error:
Traceback (most recent call last):
File "/home/pi/hkop.py", line 12, in <module>
with picamera.picamera() as camera:
AttributeError: 'module' object has no attribute 'picamera'
Can anyone help us resolve this?
import pibrella, picamera, time, random, os, sys
colours = [pibrella.light.red, pibrella.light.amber, pibrella.light.green]
def disco():
for i in range(25):
result = random.choice(colours)
result.on
time.sleep(0.2)
result.off()
with picamera.picamera() as camera:
camera.resolution = (1024, 768)
pic= 1
while True:
if pibrella.input.a.read():
camera.capture ('/home/pi/konijn/image%03d.jpg' % pic)
print("Hoera!")
os.system ('omxplayer 1-39-gcn-dk-mountain.mp3 &')
disco()
time.sleep(20)
pic += 1
time.sleep(0.01)
Upvotes: 0
Views: 7987
Reputation: 6121
picamera.PiCamera()
not:
picamera.piCamera()
and you should use:
subprocess.Popen
instead of :
os.system
Upvotes: 1
Reputation: 102902
From the docs, the class is picamera.PiCamera
. So, your with
line should be:
with picamera.PiCamera() as camera:
...
Also, as Padraic Cunningham pointed out, in your disco()
function, the line
result.on
should actually be
result.on()
as you're calling a function of the result
object.
Upvotes: 1