I have been coding a python 3 program which allows a user to easily take pictures with the raspberry pi camera. The program works up to the Camera_Capture method which takes the picture. When it is run I get this error:

if self.shutter_speed_settings_store == True:
AttributeError: 'Camera' object has no attribute shutter_speed_settings_store

the Camera_Capture method is:

def Camera_Capture(self):

    if self.name_setting == 1:
        self.picture_name = "".join((self.user_name, self.final_format))

    if self.name_setting == 2:
        self.picture_name = "".join((self.automatic_name, self.final_format))

    if self.shutter_speed_settings_store == True:
        camera.shutter_speed = self.final_shutter_speed

    if self.white_balance_setting_store == True:
        camera.white_balance = self.final_white_balance

    if self.white_balance_setting_manual_store == True:
        camera.awbgains = self.manual_white_balance

    if self.iso_setting_store == True:
        camera.iso = self.final_iso

    if self.exposure_mode_settings_store == True:
        camera.exposure_mode = self.final_exposure_mode

    if self.metering_mode_settings_store == True:
        camera.metering_mode = self.final_metering_mode_settings

    camera = picamera.PiCamera()
    print("Took the picture")

What is causing the attribute error?

If you need to see more of my code to provide a solution please leave a comment below

  • 1
    As the error states, your Camera object (which contains your Camera_Capture method) doesn't have any attribute named shutter_speed_settings_store. Judging from the name of the other attributes, might you have meant shutter_speed_setting_store? – Dave Jones Apr 11 '15 at 14:16
  • good spot I changed shutter_speed_settings_store to shutter_speed_seting_store. Still got the same error. Could the problem be to when the variable is first created? – Darth Vader Apr 11 '15 at 15:40
  • 1
    Python is simply telling you that attribute doesn't exist so either you're not setting it at all or you've spelt it wrong when setting it initially or when trying to read it later – Dave Jones Apr 11 '15 at 16:21
  • self.shutter_speed_setting_store is created as that and it is initially set as False, when the user changes the shutter setting manually it is set to True, I have checked through the code and it is called the same thing throughout the code self.shutter_speed_setting_store. when I run the program If I go through the method that changes self.shutter_speed_setting_store to True. Python then gives the attribute error but with self.white_balance_setting_store – Darth Vader Apr 11 '15 at 16:46
  • 1
    It sounds like your method initially setting the value to False is simply not getting called (especially in light of the fact that you then get the issue with white_balance_setting_store which I'm assuming is initially set in the same function). – Dave Jones Apr 11 '15 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.