user7073454 user7073454 - 1 year ago 73
Python Question

python -find which library is currently executed

I need to find out the path for a particular library in my script.

I tried using :


but it gives an attribute error:

"type object 'MODULE' has no attribute '__file__'."

Is there any other way to find the path for a particular module? I do not want to use
as it gives the list of all the libraries.

Answer Source

Actually my code was something like : from <module> import blah

I was trying to find the module path using : os.path.dirname(module.__file__) It gave an error saying "module" does not exist. So I did : import module and then from <module> import blah Then it worked !!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download