jim-easterbrook / python-gphoto2

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

error -105 GP_ERROR_MODEL_NOT_FOUND #181

Closed andrewyguo closed 2 weeks ago

andrewyguo commented 2 weeks ago

I am trying to use python-gphoto2 with my Sony A7M4 and I was getting the same errors as this issue.

I followed the advice and installed libgphoto2. I didn't comment out anything since I think there has already been a fix merged in. Please correct me if I am wrong.

Your system Python 3.9.0

Ubuntu 22.04.5 LTS

What version of libgphoto2 have you installed?

$ pkg-config --modversion libgphoto2
2.5.31.1

How have you installed (or attempted to install) python-gphoto2?

Yes. I have installed following instructions here: https://github.com/jim-easterbrook/python-gphoto2/blob/main/INSTALL.rst#local-libgphoto2

Your problem However, I am now getting this error with my A7M4:

import gphoto2 as gp

error, camera = gp.gp_camera_new()

print("error after gp_camera_new: ", error)

error = gp.gp_camera_init(camera)
print("error after gp_camera_init: ", error)

Output:

error after gp_camera_new:  0
error after gp_camera_init:  -105

Which corresponds to GP_ERROR_MODEL_NOT_FOUND.

I was not getting this before. It was able to initialize the camera fine.

jim-easterbrook commented 2 weeks ago

Check the output of python -m gphoto2 to see which version of libgphoto2 you are using.

andrewyguo commented 2 weeks ago
$ python -m gphoto2
python-gphoto2 version: 2.5.1
libgphoto2 version: 2.5.31.1, standard camlibs (SKIPPING docupen lumix), gcc, no ltdl, no EXIF
libgphoto2_port version: 0.12.2, iolibs: disk ptpip serial, gcc, no ltdl, no EXIF, no USB, serial without locking
jim-easterbrook commented 2 weeks ago

That shows it's using your local libgphoto2. You could try building an earlier version (that you know worked) and using that with python-gphoto2.

I don't think you have a python-gphoto2 bug though.

andrewyguo commented 2 weeks ago

Thanks, let me see if I can revert to an older version of libgphoto2. I am curious how @ertdfgcvb was able to fix the issue earlier. Seems like they were also using v2.5.31 of libgphoto2

jim-easterbrook commented 2 weeks ago

-105 is also the error you get if there's no camera connected (e.g. if it's gone to sleep). Worth checking - I know how easy it can be to overlook the obvious.

andrewyguo commented 2 weeks ago

@jim-easterbrook,

I made sure the camera is connected and awake. I have downgraded libgphoto to be v2.5.30. This is my gphoto version now:

$ python -m gphoto2
python-gphoto2 version: 2.5.1
libgphoto2 version: 2.5.30, standard camlibs (SKIPPING docupen), gcc, no ltdl, EXIF
libgphoto2_port version: 0.12.1, iolibs: disk ptpip serial usb usbdiskdirect usbscsi, gcc, no ltdl, EXIF, USB, serial without locking

However, I am still getting this when running python examples/camera-summary.py:

$ python examples/camera-summary.py 
WARNING: gphoto2: (gp_port_usb_close [libusb.c:309]) Invalid parameters: 'port && port->pl->dh' is NULL/FALSE.
WARNING: gphoto2: (gp_context_error) Could not detect any camera
Traceback (most recent call last):
  File "/home/ykguo/camera/python-gphoto2/examples/camera-summary.py", line 51, in <module>
    sys.exit(main())
  File "/home/ykguo/camera/python-gphoto2/examples/camera-summary.py", line 37, in main
    camera.init()
gphoto2.GPhoto2Error: [-105] Unknown model

When I run lsusb, I can see my camera.

$ lsusb
Bus 004 Device 005: ID 054c:0da7 Sony Corp. ILCE-7M4

But when I run gphoto2 --auto-detect, I get nothing:

$ ~/.local/bin/gphoto2 --auto-detect
Model                          Port                                            
----------------------------------------------------------

$ ~/.local/bin/gphoto2 --version 
gphoto2 2.5.28.1
This version of gphoto2 is using the following software versions and options:
gphoto2         2.5.28.1       gcc, popt(m), no exif, no cdk, no aa, no jpeg, no readline
libgphoto2      2.5.30         standard camlibs (SKIPPING docupen), gcc, no ltdl, EXIF
libgphoto2_port 0.12.1         iolibs: disk ptpip serial usb usbdiskdirect usbscsi, gcc, no ltdl, EXIF, USB, serial without locking
andrewyguo commented 2 weeks ago

Another thing to note, I re-installed gphoto2 using the binary wheel:

$ pip3 install gphoto2 --user --only-binary :all:
$ $ python -m gphoto2
python-gphoto2 version: 2.5.1
libgphoto2 version: 2.5.31, standard camlibs, gcc, no ltdl, EXIF
libgphoto2_port version: 0.12.2, iolibs: disk ptpip serial usb1 usbdiskdirect usbscsi vusb, gcc, no ltdl, EXIF, USB, serial without locking

But I am getting a new error:

$ python examples/camera-summary.py 
Traceback (most recent call last):
  File "/home/ykguo/camera/python-gphoto2/examples/camera-summary.py", line 51, in <module>
    sys.exit(main())
  File "/home/ykguo/camera/python-gphoto2/examples/camera-summary.py", line 37, in main
    camera.init()
gphoto2.GPhoto2Error: [-7] I/O problem
jim-easterbrook commented 2 weeks ago

If gphoto2 --auto-detect doesn't recognise your camera then python-gphoto2 won't be able to do anything with it. This is not a python-gphoto2 bug.

andrewyguo commented 2 weeks ago

I was thinking the same. Thanks for your help. I will look in the gphoto2 repository

andrewyguo commented 1 week ago

for those who encounter a similar issue, the root of my issue was this:

https://github.com/gphoto/gphoto2/issues/655