python-gphoto2
python-gphoto2 copied to clipboard
PTP General Error
Your system Python 3.9 libgphoto2 2.5.27
Your problem I've observed with several kind of camera that when the autofocus is ON, or camera not in Manual mode, there are sometime PTP errors which look like a kind of timeout.
Exemple of simple script to reproduce:
import io
import gphoto2 as gp
camera = gp.Camera()
camera.init()
gp_path = camera.capture(gp.GP_CAPTURE_IMAGE)
camera_file = camera.file_get(gp_path.folder, gp_path.name, gp.GP_FILE_TYPE_NORMAL)
data = camera_file.get_data_and_size()
with open(APPNAME + '.raw', 'wb') as fd:
fd.write(data)
Exemple of error:
Gphoto2: b'gp_context_error': b'PTP General Error'
Gphoto2: b'gp_camera_capture [gphoto2-camera.c:1324]': b"'camera->functions->capture (camera, type, path, context)' failed: -1"
Observed behaviors:
- I've never be able to reproduce the error using the
gphoto2command-line tool. - putting off the auto focus / manual mode solve the issue (but no autofocus :smile: )
Does I make something wrong in my scripts?
Check which version of libgphoto2 is being used by the gphoto2 command line tool (gphoto2 --version) and the Python interface (python3 -m gphoto2). If they are different then that could be one reason why you can't reproduce the error with the command line tool.