jim-easterbrook / python-gphoto2

Python interface to libgphoto2
GNU Lesser General Public License v3.0
357 stars 59 forks source link

PTP General Error #142

Closed anxuae closed 1 year ago

anxuae commented 2 years ago

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:

Does I make something wrong in my scripts?

jim-easterbrook commented 2 years ago

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.