Python: Submodules Not Found
Question: My Python couldn't figure out the submodules when I was trying to import
`reportlab.graphics.shapes` like this:

    
    
    >>> from reportlab.graphics.shapes import Drawing
    
    Traceback (most recent call last):
      File "<pyshell#14>", line 1, in <module>
        from reportlab.graphics.shapes import Drawing
    ImportError: No module named shapes
    

I have copied the `reportlab` package to **/site-packages** and I can import
**module reportlab.graphics** successfully.

My Python version is 2.7.3.

Could anyone help me to fix this problem?


Answer: As @dan-boa pointed out, you can add paths to the module search path, but
since you can find the parent module, I doubt that this is your root problem.

Do you have some left-over installation of the module at another path? You can
check the path where it is finding the parent package (reportlab) by
executing:

    
    
    import reportlab
    print reportlab.__file__
    

If this is indeed the path you were expecting, then try this recursively with
the the sub-modules, until you can see where the problem is. Perhaps, your
package is corrupted? Try manually checking in the path returned if you can
find the files/modules in question.

If this is not the path you were expecting, clean-up the installation from
this 2nd path and try again.

Finally, in case you do find that it is a path problem, instead of adding the
path each time using sys.path.append, you can add it to
[PYTHONPATH](http://docs.python.org/using/cmdline.html#envvar-PYTHONPATH)

