Python analog of Unix 'which'

Posted by bgbg on Stack Overflow See other posts from Stack Overflow or by bgbg
Published on 2010-04-13T12:32:25Z Indexed on 2010/04/13 13:42 UTC
Read the original article Hit count: 341

Filed under:
|

In *nix systems one can use which to find out the full path to a command. For example:

$ which python
/usr/bin/python

or whereis to show all possible locations for a given command

$ whereis python
python: /bin/python.exe /bin/python2.5-config /usr/bin/python.exe /usr/bin/python2.5-config /lib/python2.4 /lib/python2.5 /usr/lib/python2.4 /usr/lib/python2.5 /usr/include/python2.4 /usr/include/python2.5 /usr/share/man/man1/python.1

Is there an easy way to find out the location of a module in the PYTHONPATH. Something like:

>>> which (sys)
'c:\\Python25\Lib\site-packages'

© Stack Overflow or respective owner

Related posts about python

Related posts about which