jim-easterbrook / python-gphoto2

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

Missing pre-req's(?) after building libgphoto2 from source on Raspberry Pi #144

Closed greiginsydney closed 1 year ago

greiginsydney commented 1 year ago

Hi Jim,

I was chasing updates to libgphoto2 last year (#128) but held out for the 2.5.27 wheel(?) baked into Bullseye, but with its arrival I think I'm encountering the issue with the camera reporting 'busy' on its LCD and ignoring the shutter button and bulb input.

This forces me into trying to do my own builds of libgphoto2 (rather than my earlier preferred sudo apt-get install libgphoto2-dev -y).

Whilst my builds look to go OK, I'm unable to get python-gphoto to work, as below.

Odds are this is due to how I'm building libgphoto2, but I was hoping you might be able to see the error in my ways...

When I queried the Debian folk they said "These recipes should install the development header files as well, but they do so without informing the package system of your OS." Is there an install step I'm missing that's keeping libgphoto2-dev hidden from python-gphoto2?

Your system What version of Python are you using?

pi@BenchPi3BPlus:~/examples $ python3 --version
Python 3.9.2

Raspberry Pi 3B+ running Raspbian GNU/Linux 11 (bullseye)

What version of libgphoto2 have you installed?

pi@BenchPi3BPlus:~/examples $ pkg-config --modversion --errors-to-stdout libgphoto2
2.5.30.1

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

This is my current install script:

#!/bin/bash

apt-get install python3-pip build-essential libltdl-dev libusb-1.0-0-dev libexif-dev libpopt-dev libudev-dev pkg-config git automake autoconf autopoint gettext libtool wget -y

git clone https://github.com/gphoto/libgphoto2.git
cd /home/${SUDO_USER}/libgphoto2
autoreconf --install --symlink
./configure
make
make install

apt install libexif12 libgphoto2-6 libgphoto2-port12 libltdl7 -y
pip3 install -v gphoto2 --no-binary :all:

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.

pi@BenchPi3BPlus:~/examples $ python3 gphoto2_version.py
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/gphoto2/examples/gphoto2_version.py", line 24, in <module>
    import gphoto2 as gp
  File "/usr/local/lib/python3.9/dist-packages/gphoto2/__init__.py", line 27, in <module>
    from gphoto2.abilities_list import *
  File "/usr/local/lib/python3.9/dist-packages/gphoto2/abilities_list.py", line 11, in <module>
    import gphoto2.camera
  File "/usr/local/lib/python3.9/dist-packages/gphoto2/camera.py", line 12, in <module>
    import gphoto2.context
  File "/usr/local/lib/python3.9/dist-packages/gphoto2/context.py", line 13, in <module>
    import gphoto2.file
  File "/usr/local/lib/python3.9/dist-packages/gphoto2/file.py", line 14, in <module>
    import gphoto2.filesys
  File "/usr/local/lib/python3.9/dist-packages/gphoto2/filesys.py", line 15, in <module>
    import gphoto2.list
  File "/usr/local/lib/python3.9/dist-packages/gphoto2/list.py", line 16, in <module>
    import gphoto2.port_info_list
  File "/usr/local/lib/python3.9/dist-packages/gphoto2/port_info_list.py", line 17, in <module>
    import gphoto2.port_log
  File "/usr/local/lib/python3.9/dist-packages/gphoto2/port_log.py", line 18, in <module>
    import gphoto2.result
  File "/usr/local/lib/python3.9/dist-packages/gphoto2/result.py", line 19, in <module>
    import gphoto2.version
  File "/usr/local/lib/python3.9/dist-packages/gphoto2/version.py", line 20, in <module>
    import gphoto2.widget
  File "/usr/local/lib/python3.9/dist-packages/gphoto2/widget.py", line 24, in <module>
    from ._widget import *
ImportError: /usr/local/lib/libgphoto2.so.6: undefined symbol: gp_port_init_localedir, version LIBGPHOTO2_5_0

Does this reveal something? (It's Greek to me).

pi@BenchPi3BPlus:~/examples $ pkg-config --cflags --libs libgphoto2
-I/usr/local/include -I/usr/local/include/gphoto2 -I/usr/local/include -I/usr/local/include/gphoto2 -L/usr/local/lib -lgphoto2 -lm -lgphoto2_port -lm
pi@BenchPi3BPlus:~/examples $

Thanks.


- Greig.

jim-easterbrook commented 1 year ago

Why are you using apt to install libgphoto2 after you've installed your local build of it? This might be giving you two installations in different places which could confuse the Python build. The import error might be because at runtime Python is linking to a different version of libgphoto2 than the one whose header files python-gphoto2 was built with.

greiginsydney commented 1 year ago

That would be purely a misunderstanding as to what all the various components do.

I'd do a rebuild without adding libgphoto2-6 & libgphoto2-port12 and see what happens.

Thanks.

greiginsydney commented 1 year ago

Bingo! Thanks Jim. Omitting that entire line in the build script has done the trick.

I can now build to current releases of both libgphoto and python-gphoto.

pi@BenchPi3BPlus:~/examples $ python3 gphoto2_version.py
python: 3.9.2 (default, Mar 12 2021, 04:06:34)
[GCC 10.2.1 20210110]
libgphoto2: ['2.5.30.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)', 'no ltdl (for portable loading of camlibs)', 'EXIF (for special handling of EXIF files)']
libgphoto2_port: ['0.12.1', 'iolibs: disk ptpip serial usb1 usbdiskdirect usbscsi', 'gcc (C compiler used)', 'no ltdl (for portable loading of iolibs)', 'EXIF (for vusb)', 'USB (libusb1, 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.4
pi@BenchPi3BPlus:~/examples $

I appreciate the help as always.

- G.