AttributeError: 'module' object has no attribute 'mkdirs'

While creating a nested directory in Python 3.6 received following error:

AttributeError: 'module' object has no attribute 'mkdirs'

Sample code:

def create_sample_data():
    os.mkdirs("/tmp/lambdadir/ProjectTemp/mynewtest")
    f=open("/tmp/lambdadir/ProjectTemp/mynewtest/my_copy.txt","w+")
    f.write("This is inside a directory")
    f.close()

Please help.


There is no os.mkdirs. Perhaps you meant os.mkdir or os.makedirs instead?


After googling a bit, found that, its a Python version issue.

I changed code from os.mkdirs() to os.makedirs() and it worked.

Details: os module documentation

Credits: buttscicles - Reddit