I'm new to python and am trying to write a code that will allow me to take time lapse photographs with my DSLR.
I followed the code from a tutorial, but am receiving this error when I run it through the terminal.
Thanks!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
from time import sleep from datetime import datetime from sh import gphoto2 as gp import signal, os, subprocess shot_date = datetime.now().strftime( "%Y-%m-%d" ) shot_time = datetime.now().strftime( "%Y-%m-%d" "%H:%M:%S" ) pidID = "earth_test_3" clearCommand = [ "--folder" , "/store_00020001/DCIM/100CANON" , "-R" , "--delete-all-files" ] triggerCommand = [ "--trigger-capture" ] downloadCommand = [ "--get-all-files" ] folder_name = shot_date + picID save_location = "/home/pi/Desktop/earth_test_3/" + folder_name def createSaveFolder(): try : os.makedirs(save_location) print ( "New save directory created for today!" ) except : print ( "Already created this save directory for today" ) os.chdir(save_location) def captureImages(): gp(triggerCommand) sleep( 3 ) gp(downloadCommand) gp(clearCommand) def renameFiles ( ID ): for filename in os.listdir( "." ): if len (filename) < 13 : if filename.endswith( ".JPG" ): os.rename(filename, (shot_time + ID + ".JPG" )) print ( "Sucess! JPG renamed" ) elif filename.endwith ( ".CR2" ): os.rename(filename, (shot_time + ID + ".CR2" )) print ( "Hurray! Raw file renamed" ) gp(clearCommand) while True : createSaveFolder() captureImages() renameFiles(picID) sleep ( 60 ) |
Error:Traceback (most recent call last);
File "earth_test_4.py", line 3, in <module>
from sh import gphoto2 as gp
ImportError: No module named 'sh'
Any insight is much appreciated (including any better way to go about a time lapse capture!)Thanks!