3

For example, when I use pip install numpy, I can use pip show numpy to get the location of numpy package.

When I install numpy by conda, e.g. conda install numpy, how can I get the location of this package?

maplemaple
  • 1,297
  • 6
  • 24

1 Answers1

5

You need to either

  1. Open a prompt
    >>> import numpy
    >>> print(numpy.__file__)
    
  2. Use a tool that will do that. I wrote "whych" for that purpose.
    python3 -m whych numpy
    
    will show the full path to the python executable that was used. You can also show the package version with
    python3 -m whych numpy --module-version
    
    (this is optional as it requires to actually import the module). The library also works within Python (useful in jupyter notebooks for instance):
    from whych import whych
    whych("numpy")
    

As you can guess, I use the second solution. It is really convenient when you work on several computers and sometimes use pip, sometimes conda, and sometimes the package manager.

Pierre de Buyl
  • 7,074
  • 2
  • 16
  • 22