[Objective] To investigate the expression of ALDH2 in hepatocellular carcinoma and its correlation with macrophage infiltration and with the activation of specific subtypes of macrophages. [Methods] Transcriptome and clinical data from patients with hepatocellular carcinoma were downloaded from The Cancer Genome Atlas (TCGA) and the International Cancer Genome Consortium (ICGC) databases and analyzed and collated using R and Perl software. In the TCGA hepatocellular carcinoma dataset, the Wilcoxon test was used to identify macrophage activation-related gene sets that show differential expression between hepatocellular carcinoma and normal tissues. Single-cell sequencing combined with bulk data was used to analyze macrophage infiltration of hepatocellular carcinoma immune cells and the activation and recruitment of different subtypes of macrophages. Single-factor Cox regression and minimum absolute convergence and selection operator (Lasso) were used to identify survival-related genes and construct prognostic models of HCC. The patients were divided into two groups based on their model scores. The Wilcoxon test was used to identify differentially expressed genes (DEGs) between the two groups, and gene ontology (GO) and Kyoto Encyclopedia of Genes and Genomes (KEGG) functional enrichment analyses of the DEGs were performed. Single-sample gene set enrichment analysis (ssGSEA) was performed to explore the possible mechanism underlying the differences in prognosis. The reliability of the model was verified using the ICGC hepatocellular carcinoma dataset. A Kaplan‒Meier curve was constructed and used to analyze the influence of macrophage activation-related gene expression on survival and prognosis in patients with hepatocellular carcinoma. The log-rank test and the independent t test were used to analyze survival time data and to compare immune cell infiltration in the two groups. [Results] In a comparison of hepatocellular carcinoma and paracancerous tissues, the expression of six of 137 macrophage activation-related genes (ALDH2, CCNB2, CYP2C9, CYP3A4, F9 and KLKB1) was found to be significantly correlated with overall survival time (OS) in patients with hepatocellular carcinoma. Based on this finding, a prognosis assessment model for hepatocellular carcinoma was constructed. The OS of the patients in the high-scoring group was significantly shorter than the OS of the patients in the low-scoring group (P<0.05), and the model predicted the prognosis of patients with hepatocellular carcinoma independently of sex, age, tumor grade and stage. The area under the receiver operating characteristic (ROC) curve of the model used to predict 1-, 2-, and 3-year survival was greater than 0.7 in both the test set and the validation set. GO enrichment of DEGs between the high- and low-scoring groups of the model suggested that the DEGs are mainly related to immune function. GSEA suggested that the tumor-infiltrating immune cells in the high-scoring group were macrophages, Th2 cells and Treg cells and showed that the number of tumor-infiltrating immune cells, including NK cells, was lower in the high-scoring group than in the low-scoring group. With respect to immune function, the immune checkpoint of the high-scoring group was higher than that of the low-scoring group. Single-cell sequencing data indicated the recruitment of B cells, M0 cells, M1 cells and M2 cells to the hepatocellular carcinoma microenvironment and suggested that ALDH2 regulates related signaling pathways in a way that promotes the differentiation of macrophages into M2-type macrophages. [Conclusion] M2-type macrophages are the dominant type of macrophages associated with immune infiltration in hepatocellular carcinoma. The macrophage-associated activation gene ALDH2 activates the macrophage polarization signaling pathway and negatively regulates the differentiation of macrophages into M2-type macrophages.