2

I'm having some trouble getting the os.makedirs() function to work. I'm currently experimenting in IDLE's shell right now and this is the error I'm getting when trying to use this function:

os.makedirs('/delicious\walnut\waffles')

Error:

Traceback (most recent call last):
  File "<pyshell#48>", line 1, in <module>
    os.makedirs('/delicious\walnut\waffles')
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/os.py", line 223, in makedirs
    mkdir(name, mode)
OSError: [Errno 30] Read-only file system: '/delicious\\walnut\\waffles'

Im just trying to create a random new directory. I'm going through this book called "Automate the Boring Stuff" and I'm doing this as part of Chapter 8.

Harshal Parekh
  • 5,918
  • 4
  • 21
  • 43
jzieg184
  • 23
  • 4

1 Answers1

1

Its seems like the folder path you are trying to use is only available for reading, not for writing. Try changing the settings of the path.

Take a look at this:

https://support.apple.com/guide/mac-help/change-permissions-for-files-folders-or-disks-mchlp1203/mac

CMinusMinus
  • 426
  • 1
  • 3
  • 11
  • 1
    But the folder path doesn't exist yet right? That's what os.makedirs() is supposed to do I think. I believe it should create those directories. If this is so, I'm not sure how I would change the permissions on the folder if it doesn't exist. – jzieg184 Jun 07 '20 at 19:39
  • Try to change the permissions from the folder above it – CMinusMinus Jun 07 '20 at 19:51
  • have you tried adding "mode" in os.makedirs()?.mkdir (): "Creates a directory named path with numeric mode "mode". The default mode is 0777 (octal). In some systems, the mode is ignored. Where it is used, the current mask value is first masked out. Availability: Macintosh, Unix, Windows". I can direct you to this post: https://stackoverflow.com/questions/1627198/python-mkdir-giving-me-wrong-permissions to understand how it works! – Anya Samadi Jun 11 '20 at 04:55
  • Read only permissions in my case, thanks a lot – Andres Paladines Oct 20 '21 at 11:59