Skip to content Skip to sidebar Skip to footer

Invalid Filename Or Mode 'wb'

I am using django. I was trying to compress an icon uploaded by a user to a smaller size using Pythons Image library. Following is my code: def resizeImage(icon,ext): path= os

Solution 1:

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

Similar post: ioerror invalid mode w

Solution 2:

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.

Solution 3:

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.

Post a Comment for "Invalid Filename Or Mode 'wb'"