Make sure you are pointing to the same database in python as well as the driver:
DB = "<your DB consistent with the one you're executing against in browser>"
with neo4j.GraphDatabase.driver(URI, auth=AUTH) as driver:
with driver.session(database=DB) as session:
session.run(query)