How to set the current working directory? [duplicate]

How to set the current working directory in Python?


Try os.chdir

os.chdir(path)

        Change the current working directory to path. Availability: Unix, Windows.


Perhaps this is what you are looking for:

import os
os.chdir(default_path)

import os
print os.getcwd()  # Prints the current working directory

To set the working directory:

os.chdir('c:\\Users\\uname\\desktop\\python')  # Provide the new path here

It work for Mac also

import os
path="/Users/HOME/Desktop/Addl Work/TimeSeries-Done"
os.chdir(path)

To check working directory

os.getcwd()