Billy Mays 81282ed9a88799d21e77957df2d84bd6514d9af6 at
Fri Aug 5 16:43:49 CEST 2011

On 08/04/2011 10:03 PM, Chris Angelico wrote:
> On Fri, Aug 5, 2011 at 1:34 AM, Steven D'Aprano
> <steve+comp.lang.python at>  wrote:
>> Especially for a tool aimed at programmers (who else would be interested in
>> PyWhich?)
> The use that first springs to my mind is debugging import paths etc.
> If you have multiple pythons installed and aren't sure that they're
> finding the right modules, you could fire up PyWhich on an innocuous
> module like math or sys, and see if it's loading it from the right
> path. People doing this might not necessarily be programmers, they
> might be sysadmins; but you're right that it's most likely this will
> be used by competent Python programmers.
> ChrisA

I am trying to do debugging.  I have had some trouble with multiple 
python installs with virtualenv, and I was trying to see where given 
modules came from.  I knew about the code execution, but I couldn't 
think of a clean way to just find out the location rather than load it.

The reason I used stdout was because I was going to be using it in a 
tool chain where the stdout might need to be formatted for another 
program to read in.  Thats also why I was catching ImportError since a 
later version of this script might need to do something special with it.

This is also useful to see if python is really using the module you 
think it is.


More information about the Python-list mailing list