Skip to content

Commit d0c13e0

Browse files
committed
Notify if dependencies are not met.
1 parent 7562276 commit d0c13e0

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

qrcode/image/pil.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ class PilImage(qrcode.image.base.BaseImage):
1010
kind = "PNG"
1111

1212
def new_image(self, **kwargs):
13+
if not Image:
14+
raise ImportError("PIL library not found.")
15+
1316
back_color = kwargs.get("back_color", "white")
1417
fill_color = kwargs.get("fill_color", "black")
1518

qrcode/image/pure.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class PyPNGImage(BaseImage):
1414
needs_drawrect = False
1515

1616
def new_image(self, **kwargs):
17+
if not PngWriter:
18+
raise ImportError("PyPNG library not installed.")
19+
1720
return PngWriter(self.pixel_size, self.pixel_size, greyscale=True, bitdepth=1)
1821

1922
def drawrect(self, row, col):

0 commit comments

Comments
 (0)