Python: source code string cannot contain null bytes

三世轮回 提交于 2019-11-27 14:44:43
DilithiumMatrix

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 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.

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.

I've got the same error and the solution is to uninstall the Library and if you can't simply delete it and reinstall the Library. should work it has work for me...

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.

Atharva Panage
  • 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

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)).

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!