I’m using Max OS X 10.10.3, and I finally got the graphics.py to show in Python 3, before it was saying no module existed.
However, now when I try import graphics, or from graphics import *, I get the message:
"source code string cannot contain null bytes"
Does any Mac user (using Python 3) perhaps know what is wrong? Has anyone used the Zelle book and his graphics.py module? Thanks.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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
Method 2
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.
Method 3
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)).
Method 4
I just encountered this problem, which is usually caused by the encoding format. You can use Notepad++ to change the encoding format of python files to UTF-8.
Method 5
Open your file with an editor that can show you all invisible character.
You will see where is the invalid char, just delete and re-type it.
If you are on mac you can do it with Coda > Open your file > Show invisible characters.
Method 6
- Go to python folder
python36/Lib/site-packages/scipy/ - Open
__init__.py
Change:
from scipy._lib._testutils import PytestTester
to:
from scipy._lib.test__testutils import PytestTester
It worked on my windows 7
Method 7
This kind of error is not from your project source code. This kind of error emerges from your python interpreter. So the best solution is to set your python interpreter in your project env directory. or set the interpreters virtual env properly using your IDE’s interpreter configuration.
Method 8
I created a file using windows terminal echo “hello” > hello.py and got this issue. I resolved by creating a new file from notepad
Method 9
My problem was the python interpreter, try changing it to the right python directory path
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0