Python Forum
TimeLapse Help - ImportError: No module named 'sh'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TimeLapse Help - ImportError: No module named 'sh'
#1
I'm new to python and am trying to write a code that will allow me to take time lapse photographs with my DSLR.

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)
I followed the code from a tutorial, but am receiving this error when I run it through the terminal.

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!
Reply
#2
I assume you mean this module?

How to install
pip install sh
Recommended Tutorials:
Reply
#3
(Jun-25-2019, 03:18 PM)metulburr Wrote: I assume you mean this module? How to install
pip install sh
thanks for your help! I tried that before and nothing changed! it ended up going through after doing

sudo pip3 install sh 


I'm not sure yet what the main difference is here.

Now I'm getting:
Error:
Traceback (most recent call last); File "earth_test_4.py", line 15, in <module> folder_name = shot_date + picID NameError: name 'picID' is not defined"
any idea what I did incorrectly here?

---edit: I found a simple typo! My mistake
Reply
#4
so the issue is resolved?
Recommended Tutorials:
Reply
#5
(Jun-25-2019, 04:30 PM)metulburr Wrote: so the issue is resolved?

Yes, thanks!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using moviepy fails due to "ModuleNotFoundError: No module named 'pip._internal.utils sheepog 2 2,265 May-28-2025, 06:57 PM
Last Post: sheepog
  ModuleNotFoundError: No module named 'eyed3' Wimpy_Wellington 3 5,031 May-10-2025, 05:56 PM
Last Post: Wimpy_Wellington
  ModuleNotFoundError: No module named 'tkcalendar', Thonny, Windows 10 Edward_ 4 5,353 Apr-06-2025, 07:56 PM
Last Post: Edward_
  No module named 'importlib.metadata' EdVS 3 3,050 Jan-30-2025, 09:55 AM
Last Post: Larz60+
  ModuleNotFoundError: No module named 'athena_read' raman 2 2,308 Jul-01-2024, 07:52 AM
Last Post: Gribouillis
  no module named 'docx' when importing docx MaartenRo 1 8,946 Dec-31-2023, 11:21 AM
Last Post: deanhystad
  Problem with pymodbus - ModuleNotFoundError: No module named 'pymodbus.client.sync' stsxbel 2 34,930 Nov-02-2023, 08:20 AM
Last Post: South_east
  ModuleNotFoundError: No module named 'requests' Serg 18 15,467 Oct-29-2023, 11:33 PM
Last Post: Serg
  Resolving ImportError: No module named gdb (Python in C++) mandaxyz 3 7,024 Oct-04-2023, 02:43 PM
Last Post: mandaxyz
  ModuleNotFoundError: No module named 'PyPDF2' Benitta2525 1 5,259 Aug-07-2023, 05:32 AM
Last Post: DPaul

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.