This is one way of doing it, works for me at least: python::str dir = "C:/somedir"; python::object sys = python::import("sys"); sys.attr("path").attr("insert")(0, dir);