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?
you can set PYTHONPATH, by os.environ['PATHPYTHON']=/some/path, then you need to call os.system('python') to restart the python shell to make the newly added path effective.
PYTHONPATH
os.environ['PATHPYTHON']=/some/path
os.system('python')