Improve detection of Python version