This probably doesn't answer your question but I would just set your environment settings under raster storage to create pyramids. This way, it will always create pyramids. It will probably skip over those that already have them. Even if it overwrites them, that is better than it not working at all for you.