Alternative way of connecting to PIL library?
Question: Usually the library PIL is connected as follows:

    
    
    from PIL import ImageTk, Image 
    

I would like to connect it this way:

    
    
    import PIL
    

but my version does not work. Here's the code:

    
    
    import os, sys
    import tkinter
    import PIL
    
    main = tkinter.Tk()
    
    catalogImg1 = 'imgs'
    nameImg1 = 'n.jpg'
    pathImg1 = os.path.join(catalogImg1, nameImg1)
    
    openImg = PIL.Image.open(pathImg1)
    
    renderImg = PIL.ImageTk.PhotoImage(openImg)
    tkinter.Label(main, image=renderImg).pack()
    
    main.mainloop()
    

The error message is:

> Traceback (most recent call last): File
> "C:\Python33\projects\PIL_IMAGETK\ImageTK_photoimage - копия.py", line 11,
> in openImg = PIL.Image.open(pathImg1) AttributeError: 'module' object has no
> attribute 'Image'


Answer: Importing a package (`PIL`) does not automatically import subpackages,
submodules (`PIL.Image`, `PIL.ImageTk`). (Unless the package itself do it).

Explicitly import the submodules.

Replace following line:

    
    
    import PIL
    

with:

    
    
    import PIL.Image
    import PIL.ImageTk
    

