I figured this out - somehow I managed to get Python 2.7 and 3.9 on my machine, and the plain 'python' command was invoking Python 2. By using the command 'python3 myscript.py' it is now working as expected