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
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