I know how to set it in my /etc/profile and in my environment variables.
But what if I want to set it during a script? Is it import os, sys? How do I do it?
PYTHONPATH ends up in sys.path, which you can modify at runtime.
import sys sys.path += ["whatever"]