os.chdir() is not working in mac
<p>I am writing a python script to take user input and create directory and change to new directory. However when I invoke os.chdir() and os.getcwd() doesn't work as expected. (Mac OS - linux)</p>

<p>Is there any equivalent to os.chdir()</p>

<pre><code>#!/usr/bin/env python

import os
import sys

# Create a directory
directoryName = raw_input('Enter new directory name: ')
cmdToExecute = 'mkdir ' + directoryName
print cmdToExecute
os.popen(cmdToExecute)

# Change Directory
directoryPath = os.getenv('PWD')
directoryPath = directoryPath + '/' + directoryName 
os.chdir(directoryPath)
</code></pre>