ValueError: source code string cannot contain null bytes

Hello! I am new to Python and Bokeh but I have done this before… I am setting up a series of weather reporting stations on Raspberry pi zeros. I have two of them set up and working. I have been using bokeh to display the plots. on two of them. The third one is driving me nuts.

Python seems happy, at least so far as the part that records the sensor data works, and I can bring python up from the command line:

windmill:~ $ python
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux

And I can import bokeh and get the version info:

import bokeh

So that looks good.

The problem is the script to create the plots that works on the other two stations gives a long line of noise and exits with a ValueError: source code string cannot contain null bytes error.

windmill:~ $ /usr/bin/python3 ./
Traceback (most recent call last):
File “./”, line 11, in
from bokeh.plotting import figure, show, output_file, save
File “/home/joe/.local/lib/python3.7/site-packages/bokeh/plotting/”, line 20, in
from . import figure as _figure ; _figure
File “/home/joe/.local/lib/python3.7/site-packages/bokeh/plotting/”, line 20, in
from … import (
File “/home/joe/.local/lib/python3.7/site-packages/bokeh/core/”, line 286, in
from .property.dataspec import AlphaSpec; AlphaSpec
File “/home/joe/.local/lib/python3.7/site-packages/bokeh/core/property/”, line 27, in
from .datetime import Datetime, TimeDelta
File “/home/joe/.local/lib/python3.7/site-packages/bokeh/core/property/”, line 25, in
import dateutil.parser
ValueError: source code string cannot contain null bytes

I have been trying to figure this out on my own. I have tried bringing the script over again from one of the machines that works, in case it somehow got corrupted. Same error.

I thought my data may have something weird with it so I both looked at it and it looks fine and I tried pointing this script at one of the other stations raw data. Same error.

I think the problem is with bokeh, because on the other systems if I run bokeh info from the command line I get a nice summery of the system. If I run the same command on the bad system, I get the same big blast of noise and the same error.

I have tried uninstalling bokeh and re-installing it. Same error.

Any help would be appreciated. I am running out of ideas on this one! Thank you!

dateutil is a Python standard library module. This seems more like your Python installation is corrupted. What happens if you try this at the command line:

python -c"import dateutil.parser"

Hello Bryan,

Thank you for helping me! I just tried the command and I got the same error. What is the fix, remove and re-install python or is there a way to do a repair?

Personally, I would just re-install.

I looked stuff up and sudo apt-get purge python3 seemed to be about what I was looking for. That took out something like 110MB worth of stuff. After that I followed the directions to re-install circuitpython. Again the script that reads the transducer and writes the raw datafile is working but when I try the script to make the html files for the graphs that blows up.

I guess I could go back to square one but I have a lot of work in that little card outside of the python stuff. If at all possible I would like to figure this out!

@joew I am afraid I know nothing at all about circuitpython, I pretty much use Anaconda for Python installs exclusively. You might have better luck finding more relevant expertise on a circuitpython forum or issue tracker, or alternatively, a wider audience for general Python install questions on Stack Overflow.

Sadly, that makes TWO of us. I fought with it for a long time. It looked like python3-minimal had of an error in it but I was not able to get it to install properly. removing, re-installing, even force installing all got me back to the same place. In the end I rebuilt the card. There were lots of steps but they were still fresh in my mind.

There were still some issues with bokeh, but with the documentation and some surfing I was able to resolve them. What is odd is I do not recall these issues on the other two.

Numpy was making noise about missing and it required libatlas-base-dev to be installed. Pillow was making noise, ImportError: missing. Installing libopenjp2-7-dev fixed that. I also installed libtiff5 and it was mentioned in the same blurb and I suspect would have popped up next.

After all of that, the third pi is graphing it’s little heart out.

Thank you Bryan for your help.

1 Like