Skip to content Skip to sidebar Skip to footer

Python: Submodules Not Found

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

Solution 1:

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


Solution 2:

Please check your sys path and if the directory of the module is not present then add it.

import sys
sys.path.append('PATH_OF_THE_MODULE')

As site-packages is already their in the sys.path, may be therefore the package was imported successfully.


Post a Comment for "Python: Submodules Not Found"