We propose a fully ab initio theory to compute the electron density response under the perturbation in the local field. This method is based on our recently developed local dielectric response theory [Phys. Rev. B 92, 241107(R), 2015], which provides a rigorous theoretical framework to treat local electronic excitations in extended systems beyond the commonly employed dipole approximation. We have applied this method to study the electronic part of the molecular polarizability of water in ice Ih and liquid water. Our results reveal that the crystal field of the hydrogen-bond network has strong anisotropic effects, which significantly enhance the out-of-plane component and suppress the in-plane component perpendicular to the bisector direction. The contribution from the charge transfer is equally important, which increases the isotropic molecular polarizability by 5-6%. Our study provides new insights into the dielectric properties of water, which form the basis to understand the electronic excitations in water and to develop accurate polarizable force fields of water.