Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SyntaxError: invalid non-printable character U+00A0 in python [closed]

I'm getting the error:

SyntaxError: invalid non-printable character U+00A0

When I'm running the code below:

# coding=utf-8
from PIL import Image
 
img = Image.open("img.png")

I have tried to load different images with different formats (png, jpg, jpeg). I have tried using different versions of the Pillow library. I have also tried running it using python 2 and 3.

like image 859
cris.sol Avatar asked Apr 16 '26 04:04

cris.sol


1 Answers

The problem was related to a fake space found in the third line (the empty one). It is a character that looks like a space but is actually something else which is not detected by python. By removing this character the error disappeared. The character is this:

 
like image 111
cris.sol Avatar answered Apr 18 '26 16:04

cris.sol



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!