We investigate the Anderson localization in non-Hermitian Aubry-André-Harper (AAH) models with imaginary potentials added to lattice sites to represent the physical gain and loss during the interacting processes between the system and environment. By checking the mean inverse participation ratio (MIPR) of the system, we find that different configurations of physical gain and loss have very different impacts on the localization phase transition in the system. In the case with balanced physical gain and loss added in an alternate way to the lattice sites, the critical region (in the case with p -wave superconducting pairing) and the critical value (both in the situations with and without p -wave pairing) for the Anderson localization phase transition will be significantly reduced, which implies an enhancement of the localization process. However, if the system is divided into two parts with one of them coupled to physical gain and the other coupled to the corresponding physical loss, the transition process will be impacted only in a very mild way. Besides, we also discuss the situations with imbalanced physical gain and loss and find that the existence of random imaginary potentials in the system will also affect the localization process while constant imaginary potentials will not.