The first thing that comes into my mind is that the camera is used at the same time by another script or program. Please check that the camera is not used.Also, be sure that you run only an instance of the script at a time. The general idea is that the camera cannot be accessed from multiple places at a time.
Hope it helps!