I could be late here, some of the modules would throw AttributeError
when using __file__
attribute to find the path. In those case one can use __path__
to get the path of the module.
>>> import some_module
>>> somemodule.__path__
['/usr/lib64/python2.7/site-packages/somemodule']