Check for a minimum required Python version

You can check for the Python version in your code, to make sure your users are not running your script with an incompatible version. Use this simple check:

if not sys.version_info > (2, 7):
   # berate your user for running a 10 year
   # python version
elif not sys.version_info >= (3, 5):
   # Kindly tell your user (s)he needs to upgrade
   # because you're using 3.5 features
If you liked this article, please share it and help others!

Erik is the owner of Python Land and the author of many of the articles and tutorials on this website! He's been working as a professional software developer for 25 years. His favorite language of choice: Python!

Related articles

Leave a Comment