title: NameError global name 'ImageDraw' is not defined
body: <p>I am new, Hello <strong>so</strong> community</p>
  
  <p>I am devoloping with Pillow and (Tkinter,BmpImagePlugin,cStringIO,subprocess,ctype s,re .. n) modules</p>
  
  <p>I am using this way when if this situation show me AttributeError</p>
  
  <pre><code>from PIL import *
  </code></pre>
  
  <p>I solve this code line with try-except</p>
  
  <pre><code>try:
      from PIL import *
  except AttributeError: #module has no attribute ImageN
      import Image
      import ImageDraw
      import ImageFont
  </code></pre>
  
  <p>My orginal code part</p>
  
  <pre><code>class capsGen(object):
      def __init__(self):
          pass
  
      def videoGen(self,path):
          iv = InputVideoStream()
          iv.open(path)
          self.videoHead(path)
          print self.topDuration
          frameDiff = list(enumerate(iv.readframe())) #bmp -&gt; [io][1]
          self.totalFrame = frameDiff[-1][0]
          #16 imgs
          self.genImgs = []
          curImg = 0
          while True:
              if curImg &lt; 16:
                  self.genImgs.append(randint(1,self.totalFrame))
                  curImg = curImg + 1 
              else:
                  break
  
  
          try:
              src = PIL.Image.open("src.png")
              ciz = PIL.ImageDraw.draw(src)
              ft = PIL.ImageFont.truetype("arial.ttf",32)
              ciz.text((190,15),self.fileName,font=ft) #fileName
              src.save("1.png")
  
  
              #print frameDiff[5][0]
              for i in self.genImgs:
                  imj = PIL.Image.open(StringIO.StringIO(frameDiff[i][1])) #base io -&gt; [capsNo][1]
                  imj.save("%s.png"%i)
          except NameError:
              src = Image.open("src.png")
              ciz = ImageDraw.draw(src)
              ft = ImageFont.truetype("arial.ttf",32)
              ciz.text((190,15),self.fileName,font=ft) #fileName
              src.save("1.png")
  
  
              #print frameDiff[5][0]
              for i in self.genImgs:
                  imj = Image.open(StringIO.StringIO(frameDiff[i][1])) #base -&gt; [io][1]
                  imj.save("%s.png"%i)
  </code></pre>
  
  <p>My error,</p>
  
  <pre><code>Traceback (most recent call last):
    File "o.py", line 275, in (module)
      run = capsGen()
    File "o.py", line 42, in __init__
      self.videoGen() #for developers
    File "o.py", line 157, in videoGen
      ciz = ImageDraw.draw(src)
  NameError: global name 'ImageDraw' is not defined
  </code></pre>
  
  <p>But I installed Pillow module and I create empty python file in import PIL or Image..N module are working. Its isn't just working on the my_project (o.py)</p>
  
  <p>Than you for interest.
  Good works. </p>