jim-easterbrook / python-gphoto2

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

git install clone fail #78

Closed pdeman closed 5 years ago

pdeman commented 5 years ago

Hi, I have gphoto2 running correctly. (apt-get install libgphoto2-dev, apt-get install gphoto2) and now I am trying to install python-gphoto2 through the git.

git clone xxx.
cd python-gphoto2
python setup.py build_swig

and I get this error.

ERROR: libgphoto2 version 2.5.9 is not supported running build_swig swigging gphoto2 versions ['2.5.9'] error: [Errno 2] No such file or directory

I am on ubuntu 16.04 on a nvidia jetson tx1.

any idea how to solve this ? Regards,

jim-easterbrook commented 5 years ago

Sorry about this - the error message is misleading. The build_swig command appears to have run OK so you shouldn't get the message again.

I added the warning to setup.py in case someone tries to install (e.g. with pip) for a very old version of libgphoto2. (I plan to drop support for v2.4.x soon.) When you run build_swig for the first time you don't yet have a swigged interface for your installed libgphoto2, which is why you get the warning. I need to find a better way.

pdeman commented 5 years ago

but if I try to do the next step I get this errorr: python setup.py build

error: package directory 'src/swig-bi-py2-gp2.5.22' does not exist

pdeman commented 5 years ago

I retried the build_swig:

sudo python setup.py build_swig ERROR: libgphoto2 version 2.5.22 is not supported running build_swig swigging gphoto2 versions ['2.5.22'] error: [Errno 2] No such file or directory I installed libgphoto2 from git instead of apt-get as I thought I had a too old versions.

jim-easterbrook commented 5 years ago

What version does pkg-config --modversion libgphoto2 say you have? What swig directories do you have in src?

pdeman commented 5 years ago

pkg-config --modversion libgphoto2

2.5.22.1

in python-gphoto2/src I don't have any swig directories

jim-easterbrook commented 5 years ago

So build_swig failed. The message error: [Errno 2] No such file or directory is rather vague, but might indicate that swig can't be run for some reason.

pdeman commented 5 years ago

i don't know swig. is there anything I can test about it ?

jim-easterbrook commented 5 years ago

The command swig -version will show if it's installed.

I just noticed you ran build_swig using sudo. That shouldn't be necessary.

pdeman commented 5 years ago

SWIG Version 3.0.8 Compiled with g++ [aarch64-unknown-linux-gnu] Configured options: +pcre I just reinstalled it. now I have this when I run it.:

ERROR: libgphoto2 version 2.5.22 is not supported running build_swig swigging gphoto2 versions ['2.5.22']

but it continues and generates the following folder in src:

ls swig* swig-bi-py2-gp2.5.22: abilities_list.py context.py filesys_wrap.c list_wrap.c port_log_wrap.c version_wrap.c abilities_list_wrap.c context_wrap.c file_wrap.c port_info_list.py result.py widget.py camera.py file.py init.py port_info_list_wrap.c result_wrap.c widget_wrap.c camera_wrap.c filesys.py list.py port_log.py version.py

swig-bi-py3-gp2.5.22: abilities_list.py context.py filesys_wrap.c list_wrap.c port_log_wrap.c version_wrap.c abilities_list_wrap.c context_wrap.c file_wrap.c port_info_list.py result.py widget.py camera.py file.py init.py port_info_list_wrap.c result_wrap.c widget_wrap.c camera_wrap.c filesys.py list.py port_log.py version.py

swig-py2-gp2.5.22: abilities_list.py context.py filesys_wrap.c list_wrap.c port_log_wrap.c version_wrap.c abilities_list_wrap.c context_wrap.c file_wrap.c port_info_list.py result.py widget.py camera.py file.py init.py port_info_list_wrap.c result_wrap.c widget_wrap.c camera_wrap.c filesys.py list.py port_log.py version.py

swig-py3-gp2.5.22: abilities_list.py context.py filesys_wrap.c list_wrap.c port_log_wrap.c version_wrap.c abilities_list_wrap.c context_wrap.c file_wrap.c port_info_list.py result.py widget.py camera.py file.py init.py port_info_list_wrap.c result_wrap.c widget_wrap.c camera_wrap.c filesys.py list.py port_log.py version.py

but python setup.py build doesn't work: python setup.py build running build running build_py running build_ext building '_file' extension

aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/local/include -I/usr/include/libexif -I/usr/include/python2.7 -c src/swig-bi-py2-gp2.5.22/file_wrap.c -o build/temp.linux-aarch64-2.7/src/swig-bi-py2-gp2.5.22/file_wrap.o -O3 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-label -Wno-strict-prototypes -DGPHOTO2_VERSION=0x020516 src/swig-bi-py2-gp2.5.22/file_wrap.c:150:21: fatal error: Python.h: No such file or directory compilation terminated. error: command 'aarch64-linux-gnu-gcc' failed with exit status 1

jim-easterbrook commented 5 years ago

You haven't installed the Python "development headers".

pdeman commented 5 years ago

thanks, now it install but I can't import gphoto2 in python:

import gphoto2 Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/gphoto2/init.py", line 17, in from gphoto2.abilities_list import * File "/usr/local/lib/python2.7/dist-packages/gphoto2/abilities_list.py", line 9, in import gphoto2.camera File "/usr/local/lib/python2.7/dist-packages/gphoto2/camera.py", line 38, in _camera = swig_import_helper() File "/usr/local/lib/python2.7/dist-packages/gphoto2/camera.py", line 34, in swig_import_helper _mod = imp.load_module('_camera', fp, pathname, description) ImportError: /usr/local/lib/python2.7/dist-packages/gphoto2/_camera.so: undefined symbol: gp_camera_get_single_config

jim-easterbrook commented 5 years ago

I suspect this is a mixup of libgphoto2 versions. You've swigged and compiled for version 2.5.22, which includes the gp_camera_get_single_config function, but I suspect it got linked with version 2.5.9. Try running ldd /usr/local/lib/python2.7/dist-packages/gphoto2/_camera.so. This will show you the full path of the libgphoto2.so it's linked with. I expect that's an older file than your 2.5.22 installation, which is probably in a different directory.

pdeman commented 5 years ago

yes you're righ ldd shows they are linked to the previous version of libpghoto2. How can I specify which to link with during the install ?

jim-easterbrook commented 5 years ago

I don't know if you can. I'm always careful to only have one version of any library installed. You could install 2.5.22 over 2.5.9, but that might break other things.

Looking at the output of python setup.py build_ext -h I see there are --library-dirs and --rpath options. Maybe they will do what you want. (Delete your build directory, run build_ext with the extra options, then run build and install as normal.)

pdeman commented 5 years ago

almost perfect, I can import gphoto2 but it seems it doesn't know my camera

import gphoto2
context= gphoto2.gp_context_new()
camera=gphoto2.check_result(gphoto2.gp_camera_new())

camera <Swig Object of type 'Camera *' at 0x7f953424c8>

gphoto2.gp_camera_init(camera,context)

-105

camera.get_summary()

Traceback (most recent call last): File "", line 1, in gphoto2.GPhoto2Error: [-105] Unknown model

but gphoto2 knows it and can take picture: gphoto2 --summary

Camera summary:
Manufacturer: Canon Inc. Model: Canon EOS 5DS R Version: 3-1.1.2 R

jim-easterbrook commented 5 years ago

That's the usual error when it fails to detect a camera. Check that the ldd output is using the correct libgphoto2_port.so.

pdeman commented 5 years ago

yes it is ldd /usr/local/lib/python2.7/dist-packages/gphoto2/_camera.so linux-vdso.so.1 => (0x0000007f7d42a000) libgphoto2.so.6 => /usr/local/lib/libgphoto2.so.6 (0x0000007f7d362000) libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000007f7d31b000) libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007f7d1d4000) /lib/ld-linux-aarch64.so.1 (0x00000055775fd000) libgphoto2_port.so.12 => /usr/local/lib/libgphoto2_port.so.12 (0x0000007f7d1b9000) libltdl.so.7 => /usr/lib/aarch64-linux-gnu/libltdl.so.7 (0x0000007f7d1a0000) libexif.so.12 => /usr/lib/aarch64-linux-gnu/libexif.so.12 (0x0000007f7d14e000) libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007f7d0a0000) libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000007f7d08d000)

pdeman commented 5 years ago

any possibility that it's a "stupid" error about the camera name ? there are many 5D, the 5D, 5DS, 5DSR, etc ... and because it doesn't match exactly a name it doesn't work ? for example it appears in libgphoto2 in canon-eos5drs and not 5dsr in the ligphoto2/camlibs/ptp2/cameras

jim-easterbrook commented 5 years ago

I'm not aware of any significance in the camera name. I usually get a -105 error when I've left the camera untouched for a while and it's put itself into standby. Or if I forgot to turn it on in the first place.

pdeman commented 5 years ago

yes but in my case it is not the problem, gphoto2 works all the time, I removed the "automatic switch off" etc ...

jim-easterbrook commented 5 years ago

The gphoto2 command is still using the old libgphoto2 I assume. I wonder if your build of the newer version is missing something. I'd try removing it and rebuilding the Python interface to use the old version.

pdeman commented 5 years ago

actually the examples in libgphoto2 does't work either, like sample-autodetect doesn't detect anything. https://github.com/gphoto/libgphoto2/issues/385

pdeman commented 5 years ago

I'd try removing it and rebuilding the Python interface to use the old version

I need a newer version than the one that comes with apt-get, and I always have a "conflict" because when I install gvfs-backends it comes with libgphoto2, even if I already installed a version using the git.

jim-easterbrook commented 5 years ago

I was suggesting it as a temporary test to see if you can successfully build the Python interface. But as you've already established your build of libgphoto2 is at fault there's probably no need.

jim-easterbrook commented 5 years ago

You can check which options libgphoto2 was built with from within Python. Here's what I get with my current installation:

Python 3.6.5 (default, Mar 31 2018, 19:45:04) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gphoto2 as gp
>>> gp.gp_library_version(1)
['2.5.18', 'all camlibs', 'gcc (C compiler used)', 'ltdl (for portable loading of camlibs)', 'EXIF (for special handling of EXIF files)']
>>> gp.gp_port_library_version(1)
['0.12.0', 'iolibs: disk ptpip serial usb1 usbdiskdirect usbscsi', 'gcc (C compiler used)', 'ltdl (for portable loading of iolibs)', 'USB (libusb1, for USB cameras)', 'serial (for serial cameras)', 'no resmgr (serial port access and locking)', 'no ttylock (serial port locking)', 'lockdev (serial port locking)']

(This is libgphoto2 from openSUSE repository, not a version I've compiled.)