jim-easterbrook / python-gphoto2

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

Error No. 105 Unknown Model #126

Closed mashly closed 3 years ago

mashly commented 3 years ago

This page is for reporting problems with the Python interface to libgphoto2. If your question is about using libgphoto2 you should ask on the gphoto2 mailing list.

Your system What version of Python are you using? Python 3.7 on a Rpi 3B What version of libgphoto2 have you installed? gphoto2 2.5.15 gcc, popt(m), exif, cdk, aa, jpeg, readline libgphoto2 2.5.16 all camlibs, gcc, ltdl, EXIF libgphoto2_port 0.12.0 iolibs: disk ptpip serial usb1 usbdiskdirect usbscsi, gcc, ltdl, USB, serial without locking

How have you installed (or attempted to install) python-gphoto2? Latest git version using swig Tried both SWIG and pip (uninstalled). Currently on swig. Able to import gphoto2 as gp (So I believe it's installed correctly.)

Your problem Please describe what you are trying to do and what goes wrong. A short Python script that shows the problem may be useful.

I am trying to connect my camera, a Nikon D810 to the RPI and it is in the supported list according to libgphoto2's website on python 3.7

The camera is being detected when using the regular gphoto2

pi@raspberrypi:/usr/local/lib/python3.7/dist-packages/gphoto2$ gphoto2 --auto-detect
Model                          Port                                            
----------------------------------------------------------
Nikon DSC D810                 usb:001,008     

However when I try to run examples/camera-summary.py,, I encounter the unknown model error

pi@raspberrypi:~/python-gphoto2/examples $ python3 camera-summary.py
WARNING: gphoto2: (gp_port_serial_close [unix.c:473]) Invalid parameters: 'path' is NULL/FALSE.
WARNING: gphoto2: (gp_context_error) Could not detect any camera
Traceback (most recent call last):
  File "camera-summary.py", line 43, in <module>
    sys.exit(main())
  File "camera-summary.py", line 34, in main
    camera.init()
gphoto2.GPhoto2Error: [-105] Unknown model

Any help would be appreciated

jim-easterbrook commented 3 years ago

Has the camera turned itself off between you running the gphoto2 command and the Python script? I can't think of any other reason why it would fail.

mashly commented 3 years ago

No the camera is connected all the way

jim-easterbrook commented 3 years ago

Check (using ldd) that the gphoto2 binary and the Python shared object files (in /usr/local/lib/python3.7/dist-packages/gphoto2 or similar) are linked with the same libraries.

mashly commented 3 years ago

For gphoto2 binary

pi@raspberrypi:~/gphoto2/gphoto2 $ ldd gphoto2
    linux-vdso.so.1 (0x7ef2d000)
    libgphoto2.so.6 => /lib/arm-linux-gnueabihf/libgphoto2.so.6 (0x76f26000)
    libgphoto2_port.so.12 => /lib/arm-linux-gnueabihf/libgphoto2_port.so.12 (0x76f0c000)
    libjpeg.so.62 => /lib/arm-linux-gnueabihf/libjpeg.so.62 (0x76ec6000)
    libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76e9c000)
    libexif.so.12 => /lib/arm-linux-gnueabihf/libexif.so.12 (0x76e59000)
    libpopt.so.0 => /lib/arm-linux-gnueabihf/libpopt.so.0 (0x76e3e000)
    libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76dbc000)
    libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76c6e000)
    libltdl.so.7 => /lib/arm-linux-gnueabihf/libltdl.so.7 (0x76c56000)
    /lib/ld-linux-armhf.so.3 (0x76fce000)
    libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76c43000)

For python shared object files

pi@raspberrypi:/usr/local/lib/python3.7/dist-packages/gphoto2 $ ldd _camera.cpython-37m-arm-linux-gnueabihf.so
    linux-vdso.so.1 (0x7ef87000)
    libgphoto2.so.6 => /usr/local/lib/libgphoto2.so.6 (0x76e88000)
    libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76def000)
    libgphoto2_port.so.12 => /usr/local/lib/libgphoto2_port.so.12 (0x76dd5000)
    libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76dab000)
    libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76c5d000)
    /lib/ld-linux-armhf.so.3 (0x76f46000)
    libltdl.so.7 => /lib/arm-linux-gnueabihf/libltdl.so.7 (0x76c45000)
    libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76c32000)

O thanks, it seems to be different? Is there a way to fix it?

EDIT: I just ran gphoto2_version.py

pi@raspberrypi:/usr/local/share/python-gphoto2/examples $ python3 gphoto2_version.py
python: 3.7.3 (default, Jan 22 2021, 20:04:44) 
[GCC 8.3.0]
libgphoto2: ['2.5.27.1', 'standard camlib set SKIPPING SOME (ax203 canon digigr8 dimagev directory jl2005a jl2005c kodak_dc240 mars pentax ptp2 ricoh_g3 sierra sonix sq905 st2205 topfield tp6801 SKIPPING docupen lumix)', 'gcc (C compiler used)', 'ltdl (for portable loading of camlibs)', 'no EXIF (for special handling of EXIF files)']
libgphoto2_port: ['0.12.0', 'iolibs: disk ptpip serial', 'gcc (C compiler used)', 'ltdl (for portable loading of iolibs)', 'no EXIF (for vusb)', 'no USB (for USB cameras)', 'serial (for serial cameras)', 'no resmgr (serial port access and locking)', 'no ttylock (serial port locking)', 'no lockdev (serial port locking)']
python-gphoto2: 2.3.0

this is what I got. I realised there are serial port access and locking? I'm not sure if it is normal. This is being done while the camera is plugged in and switched on

In contrast, gphoto2 --version gives me the following

pi@raspberrypi:/usr/local/bin $ gphoto2 --version
gphoto2 2.5.27.1

Copyright (c) 2000-2021 Marcus Meissner and others

gphoto2 comes with NO WARRANTY, to the extent permitted by law. You may
redistribute copies of gphoto2 under the terms of the GNU General Public
License. For more information about these matters, see the files named COPYING.

This version of gphoto2 is using the following software versions and options:
gphoto2         2.5.27.1       gcc, popt(m), exif, no cdk, no aa, jpeg, no readline
libgphoto2      2.5.22         all camlibs, gcc, ltdl, EXIF
libgphoto2_port 0.12.0         iolibs: disk ptpip serial usb1 usbdiskdirect usbscsi, gcc, ltdl, USB, serial without locking

Seems like a different libgphoto2? I'm very unclear and new to this sorry!

jim-easterbrook commented 3 years ago

The gphoto2 binary is linked with a different libgphoto2, so it's probably a newer version that recognises your camera. During normal installation of python-gphoto2 the command pkg-config --libs libgphoto2 is used to find which libraries to link to. If you've got newer libraries installed somewhere non-standard (e.g. /lib/arm-linux-gnueabihf/ instead of /usr/local/lib/) it won't know about them.

mashly commented 3 years ago

So I should remove gphoto2 libgphoto2 and python-gphoto2 now, reinstall libgphoto2 into /usr/local/lib, install gphoto2 and python-gphoto2 right?

jim-easterbrook commented 3 years ago

I don't know. I'm not very familiar with the "normal" library locations on Raspbian. Did you install gphoto2 with apt-get? If so, then it should be using the standard locations.Using apt-get to install the development headers of libgphoto2 should put them in the right place, then installing python-gphoto2 should find them. Deleting any other versions would probably be sensible, unless something else is using them.

mashly commented 3 years ago

Ok so what I did was remove prior installations to gphoto2, libgphoto2 and python-gphoto2 that I had. Had to manually remove any trace of previous libgphoto2 by sudo rm found in my /usr/local/lib and anything inside my python3.7 dist-utils

Did a clean install of libgphoto2-dev via sudo apt-get install libgphoto2-dev Did a clean install gphoto2 via sudo-apt-get install gphoto2 Did a clean install of python-gphoto2 via sudo pip3 install -v gphoto2

A functional install check would be good by doing

For python-gphoto2

pi@raspberrypi:/usr/local/lib/python3.7/dist-packages/gphoto2 $ ldd _camera.cpython-37m-arm-linux-gnueabihf.so 
    linux-vdso.so.1 (0x7edca000)
    libgphoto2.so.6 => /lib/arm-linux-gnueabihf/libgphoto2.so.6 (0x76e79000)
    libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76df7000)
    libgphoto2_port.so.12 => /lib/arm-linux-gnueabihf/libgphoto2_port.so.12 (0x76ddd000)
    libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76db3000)
    libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76c65000)
    /lib/ld-linux-armhf.so.3 (0x76f56000)
    libltdl.so.7 => /lib/arm-linux-gnueabihf/libltdl.so.7 (0x76c4d000)
    libexif.so.12 => /lib/arm-linux-gnueabihf/libexif.so.12 (0x76c0a000)
    libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76bf7000)

For gphoto2

pi@raspberrypi:/usr/local/share $ which gphoto2
/usr/local/bin/gphoto2
pi@raspberrypi:/usr/local/share $ cd /usr/local/bin
pi@raspberrypi:/usr/local/bin $ ldd gphoto2
    linux-vdso.so.1 (0x7efea000)
    libgphoto2.so.6 => /lib/arm-linux-gnueabihf/libgphoto2.so.6 (0x76e2d000)
    libgphoto2_port.so.12 => /lib/arm-linux-gnueabihf/libgphoto2_port.so.12 (0x76e13000)
    libjpeg.so.62 => /lib/arm-linux-gnueabihf/libjpeg.so.62 (0x76dcd000)
    libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76da3000)
    libexif.so.12 => /lib/arm-linux-gnueabihf/libexif.so.12 (0x76d60000)
    libpopt.so.0 => /lib/arm-linux-gnueabihf/libpopt.so.0 (0x76d45000)
    libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76cc3000)
    libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76b75000)
    libltdl.so.7 => /lib/arm-linux-gnueabihf/libltdl.so.7 (0x76b5d000)
    /lib/ld-linux-armhf.so.3 (0x76ed5000)
    libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76b4a000)

This is done on raspbian and I believe this is the default location on where the apt-get installed packages are installed to rather than the default /usr/local. Feel free to close the issue and thanks for your assistance!