1

Why my python just throw an error call:

code, fname = _get_code_from_file(run_name, path_name)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 239, in _get_code_from_file
code = compile(f.read(), fname, 'exec')
ValueError: source code string cannot contain null bytes

It was fine yesterday and it just have problem today.

It was never happened before and I don't know What is null bytes

Other people have this problem are all because using UTF-16 etc. but I'm really using UTF-8 and it really made me headache.

My IDE is VSCode and I'm using UTF-8

6
  • stackoverflow.com/questions/58656385/… Commented Feb 23, 2022 at 7:02
  • @balu It's not same problem because I'm not using OpenCV or numpy Commented Feb 23, 2022 at 7:04
  • irrespective of OpenCV or NumPy check this answer here. stackoverflow.com/a/58656445/4286568 Commented Feb 23, 2022 at 7:10
  • @balu I do like what he said, copy+paste, but the problem was still there. and I'm not using UTF-18, instead, I'm using UTF-8. I'm not pro of python and I don't know other problem in my program. Commented Feb 23, 2022 at 7:15
  • check what is there in line 239 of the .py file . open in notepad++ and see for any hidden chars that might have crept. Commented Feb 23, 2022 at 7:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.