我正在和我的孩子一起使用涉及兔子的项目(原始项目:仓鼠凸轮,http://www.raspberrypi.org/learning/hamster-party-cam/worksheet.md)攀登学习曲线。我们按照说明进入了下面的程序。
当我们运行它时,它会给出这个相当模糊的错误:
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'
任何人都可以帮我们解决这个问题吗?
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)
答案 0 :(得分:1)
从docs开始,该课程为picamera.PiCamera
。因此,您的with
行应为:
with picamera.PiCamera() as camera:
...
另外,正如Padraic Cunningham指出的那样,在disco()
函数中,行
result.on
实际应该是
result.on()
因为您正在调用result
对象的函数。
答案 1 :(得分:1)
picamera.PiCamera()
不
picamera.piCamera()
你应该使用:
subprocess.Popen
而不是:
os.system