In the treatment of non-small cell lung cancer (NSCLC), recent advances in immunotherapy have heralded a new era. Despite the success of immune therapy, a subset of patients persistently fails to respond. Therefore, to better improve the efficacy of immunotherapy and achieve the purpose of precision therapy, the research and exploration of tumor immunotherapy biomarkers have received much attention. Single-cell transcriptomic profiling was used to reveal tumor heterogeneity and the microenvironment in NSCLC. The Cell-type Identification by Estimating Relative Subsets of RNA Transcripts (CIBERSORT) algorithm was utilized to speculate the relative fractions of 22 infiltration immunocyte types in NSCLC. Univariate Cox and least absolute shrinkage and selection operator (LASSO) regression analyses were used for the construction of risk prognostic models and predictive nomograms of NSCLC. Spearman's correlation analysis was employed to explore the relationship between risk score and tumor mutation burden (TMB) and immune checkpoint inhibitors (ICIs). Screening of chemotherapeutic agents in the high- and low-risk groups was performed with the "pRRophetic" package in R. Intercellular communication analysis was conducted using the "CellChat" package. We found that most tumor-infiltrating immune cells were T cells and monocytes. We also found that there was a significant difference in the tumor-infiltrating immune cells and ICIs across different molecular subtypes. Further analysis showed that M0 and M1 mononuclear macrophages were significantly different in different molecular subtypes. The risk prediction model was shown to have to ability to accurately predict the prognosis, immune cell infiltration, and chemotherapy efficacy of patients in the high and low-risk groups. Finally, we found that the carcinogenic effect of migration inhibitory factor (MIF) is mediated by binding to CD74, CXCR4, and CD44 receptors involved in MIF cell signaling. We have revealed the tumor microenvironment (TME) of NSCLC through single-cell data analysis and constructed a prognosis model of macrophage-related genes. These results could provide new therapeutic targets for NSCLC.