ModuleNotFoundError: No module named 'PIL'

Yes, it succeeds.

Hooray.

python3.6 png2jpg.py Dust_Collector.png
Saved as Dust_Collector.png.jpg

Eventually I want to fix it so it outputs Dust_Collector.jpg.

Hmm, Discourse’s email interface has dropped the end of your post. I’ll
snarf it from the forum.

Your code, with some remarks interspersed:

 if len(sys.argv) > 1:
     if os.path.exists(sys.argv[1]):
         im = Image.open(sys.argv[1])

I’d be using a better variable name, eg:

 srcfilename = argv[1]

and then:

 if os.path.exists(srcfilename):
     im = Image.open(srcfilename)

and so on.

 # Backspace 4 spaces  and add .jpg    
 target_name = "sys.argv[1] - 4" + ".jpg"

You’ve enclosed sys.argv[1] - 4 in quotes, which makes it the literal
string "sys.argv[1] - 4". You want:

 target_name = sys.argv[1][:-4] + ".jpg"

You can’t subtract an integer from a string (sys.argv[1] - 4) but if
you want the string except the last 4 characters you can index the
string with a slice [:-4] which means the characters in the string
from the first character up to (and not including) the fourth last
character.

The requires special knowledge of the length of the original extension.
The os.path module has a function to break a filename into its base
and extension called splitext. Using it:

 # up the top
 from os.path import splitext

 # here
 src_base, src_ext = splitext(sys.argv[1])
 target_name = src_base + '.jpg'

os.path.splitext docs

You could also use a format string (“f-string”) to compute target_name
like this:

 target_name = f'{src_base}.jpg'

which most people find more readable.

 else:
     print("Usage: convert2jpg.py <file>")

I usually put this up the top, with an early return:

 if len(argv) < 2:
     print("Usage: convert2jpg.py <file>", file=sys.stderr)
     sys.exit(2)

 src_filename=argv[1]
 ... rest of the program ...

Cheers,
Cameron Simpson cs@cskk.id.au