Characterizing and Detecting Python Version Incompatibilities Caused by Inconsistent Version Specifications
Shuo Li, Haocheng Gao, Wei Chen, Yi Li, Haoxiang Tian, Chengwei Liu, and Dan Ye
Journal of Systems and Software, 2025
Abstract: Python interpreter serves as the foundation for developing Python projects. Configuring compatible Python version is essential for packaging and reusing third-party libraries (TPLs) in the Python ecosystem. When the Python distribution version range constraint of a third-party library is incorrectly declared, it may lead to installation failures or runtime errors when the library is used by a client project. We call such errors Python Distribution Version Specification Error (PDSpecErr). PDSpecErrs are not studied adequately and there still lacks a method to guarantee the correctness of Python version specifications. To combat PDSpecErrs and mitigate their adverse impacts on downstream applications, we conducted the first exploratory study on 3,000 real-world TPLs to investigate PDSpecErrs about their prevalence, symptom categories, and diagnostic patterns. Based on the comprehensive study, we designed and implemented PyChecker, a tool to automatically detect PDSpecErrs in TPLs, locate root causes, and generate fixing solutions. We evaluated PyChecker on 3,000 TPL releases and PyChecker detected 842 PDSpecErrs, reporting their root causes and recommending fixing solutions. We have reported 52 PDSpecErrs to the concerned developers. So far, 32 issues have been confirmed and fixed according to our suggestions.