[Answered ]-Invalid filename or mode 'wb'

2đź‘Ť

What solved it for me was switching from backslashes to forward slashes! Who would’ve thought?!

Similar post: ioerror invalid mode w

👤Stef g

1đź‘Ť

Check your file path if it’s valid:

C:/Users/Silent/Documents/Python/karnadash/karnadash/static/tempfiles/temp.jpg

Perhaps it contains one karnadash too much.

👤matino

-1đź‘Ť

I had a similar problem when I was trying to save some figures in a fowder. Some figures I could save, but couldn’t save others, and I was using the same code. I realized that the name of the figure and the backslash were in conflict with a reserved code.

IOError: [Errno 22] invalid mode ('wb') or filename: '02102016\nDTG.png'

I think "\n" was interpreted as “enter”. The problem had been solved when I changed it to forward slash.

👤Cristiano

Leave a comment