i have an image like this:

after I skeletonize it by scikit image's skeletonize function
from skimage import morphology
out = morphology.skeletonize(gray>0)

There is a way for counting the number of black spaces? (in this picture six) except the background in scikit-image or mahotas?

With this input:
You can do:
I subtract 2 to ignore the background component and the foreground/line component. From your original image you can skip out the skeletonize step and just run this with
im = gray > 0, since the wide foreground/line will still be labelled as a single component.