How to set the current working directory?
919,008
Solution 1
Try os.chdir
os.chdir(path)
Change the current working directory to path. Availability: Unix, Windows.
Solution 2
Perhaps this is what you are looking for:
import os
os.chdir(default_path)
Solution 3
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
Solution 4
It work for Mac also
import os
path="/Users/HOME/Desktop/Addl Work/TimeSeries-Done"
os.chdir(path)
To check working directory
os.getcwd()
Comments
-
ricardo over 3 years
How to set the current working directory in Python?