Path.walk was added in Python 3.12, so you propably using an older version.
Path.walk
You can check the version in python with:
import sys print(sys.version)
Instead, use os.walk or Path.glob() (or update your Python)
os.walk
Path.glob()