import os
import sys
module_path = os.path.abspath(os.path.join('whatever_path'))
if module_path not in sys.path:
    sys.path.append(module_path)

Copied from here.