cd is the shell command to change the working directory.
cd
How do I change the current working directory in Python?
The Path objects in path library offer both a context manager and a chdir method for this purpose:
Path
chdir
from path import Path with Path("somewhere"): ... Path("somewhere").chdir()