This paper proposes a generalized model to cover imperfect debugging and the uncertainty of the operating environment and its effect on fault detection rate into software reliability evaluation based on a non-homogeneous Poisson process (NHPP). Many NHPP software reliability growth models (SRGMs) have been developed to estimate the software reliability measures over the past 40 years, but most of these models assume that the operating environment is the same as the testing environment. However, in fact, due to the unpredictability of the uncertain factors in the operating environments for the software, they may considerably influence the software's reliability in an unpredictable way. So when a software system works in a field environment, its reliability is usually different from the original reliability prediction in the testing phase of the software development process, also from all its similar applications in other fields. In this paper, a general model is used to derive models that incorporate the uncertainty of operating environments, which provides the flexibility in considering a different fault detection rate and random environmental factor and so on. Several published models are shown to be covered by this general model and a new model is also developed and examined. The numerical illustrative examples of the proposed model have been validated on two sets of real software failure data in terms of six criteria. The comparison results demonstrate that the new model can fit and predict significantly better than other existing models.