macos – Python: source code string cannot contain null bytes

macos – Python: source code string cannot contain null bytes

For posterity: I had the same problem and fixed it using,

sed -i s/x0//g FILENAME

The file seemed to be messed up in numerous ways (wrong endings, etc); no idea how…

See https://stackoverflow.com/a/2399817/230468

I am using Visual Studio Code, the encoding was set to UTF-16 LE.
You can check the encoding on the right bottom side of VSCode. Just click on the encoding and select save with encoding and select UTF-8. It worked perfectly.

macos – Python: source code string cannot contain null bytes

I got this message when I wanted to use eval for my input for my function that sometimes it takes string or int/float but when it takes numpy numbers, it throws this exception, eval(number).

My solution was eval(str(number)).

Leave a Reply

Your email address will not be published.