Is there an easy way in Python to resolve path operators like ..
? For instance is there a function call that will convert: /../../test/../path
to /path
?
Changing the Current Working Directory in Python To change the current working directory in Python, use the chdir() method. The method accepts one argument, the path to the directory to which you want to change. The path argument can be absolute or relative.
1 Answer. Or probably just export PATH="/usr/bin:$PATH" would work, since you probably just need python to be found in that directory before the anaconda directories which are at the start of your path.
You can use os.path.realpath()
to get the canonical path. To get a normalised relative path, use os.path.normpath()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With