Checking module compatibility before upgrading? - Python Help - Discussions on Python.org
Checking module compatibility before upgrading? Python Help Winfried (Winfried) December 31, 2024, 5:51pm 1 Hello, To make sure things don’t break after upgrading Python, is there a command to check that all the modules currently installed will keep working? I’ve seen this command. Is it reliable? #run before upgrading! pip3 freeze > python_requirements.txt #dry run python -m pip install -r python_requirements.txt --dry-run --python-version 3.13.1 --no-deps --target foo | grep ERROR Incidently, can the installer be told to download and install all the modules, so that the user doesn’t have to know/remember to run the “pip3 freeze” command beforehand?
Thank you. Lucas_Malor (Lucas Malor) December 31, 2024, 8:54pm 2 Maybe I’m wrong, but I think you should not run the first command. It will store the current packages in python_requirements.txt . The second command will simulate the install reading from python_requirements.txt . If you overwrite it with your current packages, it will succeed every time. You should run only the second command with the new python_requirements.txt BrenBarn (Brendan Barnwell) December 31, 2024, 9:52pm 3 The --python-version argument to pip will make it evaluate the dependencies in the context of the given Python version, so it should fail if something in the current set of packages is incompatible with the given version (3.13.1 in the example). hauntsaninja (Shantanu Jain) January 1, 2025, 9:45am 4 Check out this project of mine: GitHub - hauntsaninja/python_readiness: Are your dependencies ready for new Python?
Winfried (Winfried) January 1, 2025, 4:39pm 5 Thanks for the link. I’m suprised Python didn’t already have something available for such a common need. pip install python_readiness pip freeze > python_requirements.txt python_readiness -r python_requirements.txt --python 3.13 DevBhuyan (Devvjiit Bhuyan) February 14, 2025, 8:54pm 6 Why didn’t we have this earlier! Thanks a lot @Winfried for introducing us to this package.