Searene
Searene

Reputation: 27644

How to find the path of a module in python

from aqt import mw

It is from an anki(a program make in python) add-on source code, where can I find the mw file? I found folder /usr/share/anki/aqt, but I didn't find mw folder or mw.py file, where else could it be? Or is there method to display its path?

Upvotes: 0

Views: 261

Answers (3)

Antoine
Antoine

Reputation: 1070

to identify the type of mw, do type(mw) in your python console. It might be something defined in the __init__.py file of the aqtdir. If 'mw' is a module, then you can try mv.__file__.

Upvotes: 2

You should check this out.

from aqt import mw
print mw.__file__

Edit: wtf? "Trivial answer converted to comment"?

Upvotes: 1

xecgr
xecgr

Reputation: 5193

Start python interpreter with -v flag, for every import its path will be printed like a comment
Here an example with a funny module:

user@host ~/$ python -v
###
#a bunch of bultin imports
###
>>> import sexmachine
import sexmachine # directory /usr/local/lib/python2.7/dist-packages/sexmachine
# /usr/local/lib/python2.7/dist-packages/sexmachine/__init__.pyc matches /usr/local/lib/python2.7/dist-packages/sexmachine/__init__.py
import sexmachine # precompiled from /usr/local/lib/python2.7/dist-packages/sexmachine/__init__.pyc

Upvotes: 1

Related Questions