where python packages are installed code example

Example 1: find location of library python linux

import module_name

print(module_name.__file__)

Example 2: how to find where python modules are installed

# this will show where numpy is installed
pip show numpy

Example 3: where are python libraries installed in windows

Python usually stores its library (and thereby your site-packages folder) 
in the installation directory. So, if you had installed Python to 
C:\Python\, the default library would reside in C:\Python\Lib\ 
and third-party modules should be stored in C:\Python\Lib\site-packages.