jim-easterbrook / python-gphoto2

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

ImportError: No module named _camera #48

Closed mapoga closed 6 years ago

mapoga commented 6 years ago

First of all thank you for your project. It is everything i was looking for. I got this error after installation when i tried one of the example files.

Shell command:

pi@raspberrypi_01:/usr/local/share/python-gphoto2/examples $ python camera-summary.py
Traceback (most recent call last):
  File "camera-summary.py", line 25, in <module>
    import gphoto2 as gp
  File "/usr/local/lib/python2.7/dist-packages/gphoto2/__init__.py", line 17, in <module>
    from gphoto2.abilities_list import *
  File "/usr/local/lib/python2.7/dist-packages/gphoto2/abilities_list.py", line 9, in <module>
    import gphoto2.camera
  File "/usr/local/lib/python2.7/dist-packages/gphoto2/camera.py", line 31, in <module>
    _camera = swig_import_helper()
  File "/usr/local/lib/python2.7/dist-packages/gphoto2/camera.py", line 30, in swig_import_helper
    return importlib.import_module('_camera')
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named _camera

Build steps:

wget https://raw.githubusercontent.com/gonzalo/gphoto2-updater/master/gphoto2-updater.sh && chmod +x gphoto2-updater.sh && sudo ./gphoto2-updater.sh
sudo apt-get install python-dev
sudo apt-get install libgphoto2-2-dev
sudo pip install gphoto2

When i run "gphoto2 --summary" in the shell everything is fine.

mapoga commented 6 years ago

As it might be asked, here is what is listed in "/usr/local/lib/python2.7/dist-packages/gphoto2".

pi@raspberrypi_01:/usr/local/lib/python2.7/dist-packages/gphoto2 $ ls
abilities_list.py   file.py       list.pyc            result.pyc
abilities_list.pyc  file.pyc      _list.so            _result.so
_abilities_list.so  _file.so      port_info_list.py   version.py
camera.py           filesys.py    port_info_list.pyc  version.pyc
camera.pyc          filesys.pyc   _port_info_list.so  _version.so
_camera.so          _filesys.so   port_log.py         widget.py
context.py          __init__.py   port_log.pyc        widget.pyc
context.pyc         __init__.pyc  _port_log.so        _widget.so
_context.so         list.py       result.py
jim-easterbrook commented 6 years ago

Find the gphoto2 command executable (with which gphoto2) and run ldd on it to see which gphoto2 libraries it's using, then run ldd on _camera.so and check it's using exactly the same libraries.

mapoga commented 6 years ago

Thanks a lot for your help. I wouldn't even know where to begin otherwise. Here is what is got:

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

gphoto2 pi@raspberrypi_01:/usr/local/bin $ ldd gphoto2 linux-vdso.so.1 (0x7ee06000) /usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76f65000) libgphoto2.so.6 => /usr/lib/arm-linux-gnueabihf/libgphoto2.so.6 (0x76ec8000) libgphoto2_port.so.12 => /usr/local/lib/libgphoto2_port.so.12 (0x76eaf000) libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76e87000) libexif.so.12 => /usr/lib/arm-linux-gnueabihf/libexif.so.12 (0x76e44000) libpopt.so.0 => /lib/arm-linux-gnueabihf/libpopt.so.0 (0x76e29000) libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76dad000) libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76c6c000) libgphoto2_port.so.10 => /usr/lib/arm-linux-gnueabihf/libgphoto2_port.so.10 (0x76c54000) libltdl.so.7 => /usr/lib/arm-linux-gnueabihf/libltdl.so.7 (0x76c3c000) /lib/ld-linux-armhf.so.3 (0x54adb000) libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76c29000)

_camera.so pi@raspberrypi_01:/usr/local/lib/python2.7/dist-packages/gphoto2 $ ldd _camera.so linux-vdso.so.1 (0x7eed5000) /usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76f49000) libgphoto2.so.6 => /usr/lib/arm-linux-gnueabihf/libgphoto2.so.6 (0x76eac000) libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76e31000) libgphoto2_port.so.12 => /usr/local/lib/libgphoto2_port.so.12 (0x76e18000) libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76df0000) libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76caf000) /lib/ld-linux-armhf.so.3 (0x54aaa000) libgphoto2_port.so.10 => /usr/lib/arm-linux-gnueabihf/libgphoto2_port.so.10 (0x76c96000) libltdl.so.7 => /usr/lib/arm-linux-gnueabihf/libltdl.so.7 (0x76c7e000) libexif.so.12 => /usr/lib/arm-linux-gnueabihf/libexif.so.12 (0x76c3b000) libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76c28000)

All i can see is that "libpopt.so.0" doesnt have a match in "_camera"

jim-easterbrook commented 6 years ago

I suggested the ldd tests as there were similar problems in #46. As you say, both are using the same libraries. I'm slightly worried that they are both linking to two versions of libgphoto2_port.so, one of which is in `/usr/local/lib', unlike all the other libraries. But as gphoto2 is working that may not be a problem.

It might be worth trying a forced reinstall of python-gphoto2:

sudo pip install -v -U --force-reinstall gphoto2
mapoga commented 6 years ago

The force reinstall went successfully but nothing has changed.

jim-easterbrook commented 6 years ago

I'm still worried that you seem to have bits of two different versions of libgphoto2 installed. I suspect the updater script you used will have installed the headers anyway, so there may be no need to install libgphoto2-2-dev afterwards, especially as it may install the old version of libgphoto2 as a dependency.

mapoga commented 6 years ago

You were right, the 2 versions of libgphoto2_port.so created the problem. Right now python gphoto2 seems to behave normally. I get and error(which i did not have before) but its coming from the CLI as well. A quick search on the web indicates a udev/hwdb related problem. I will have to investigate since im new to everything linux. Thanks a lot for your help! Here are some related info:

What i did in order to try and fix the 2 versions of libgphoto2_port.so:

sudo pip uninstall gphoto2
sudo apt-get purge libgphoto2-2-dev
wget https://raw.githubusercontent.com/gonzalo/gphoto2-updater/master/gphoto2-updater.sh && chmod +x gphoto2-updater.sh && sudo ./gphoto2-updater.sh

Here is the ldd: gphoto2

pi@raspberrypi_01:/usr/local/bin $ ldd gphoto2
        linux-vdso.so.1 (0x7ed93000)
        /usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76f74000)
        libgphoto2.so.6 => /usr/local/lib/libgphoto2.so.6 (0x76ed2000)
        libgphoto2_port.so.12 => /usr/local/lib/libgphoto2_port.so.12 (0x76eb9000)
        libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76e91000)
        libexif.so.12 => /usr/lib/arm-linux-gnueabihf/libexif.so.12 (0x76e4e000)
        libpopt.so.0 => /lib/arm-linux-gnueabihf/libpopt.so.0 (0x76e33000)
        libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76db7000)
        libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76c76000)
        libltdl.so.7 => /usr/lib/arm-linux-gnueabihf/libltdl.so.7 (0x76c5e000)
        /lib/ld-linux-armhf.so.3 (0x54ab7000)
        libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76c4b000)

_camera.so

pi@raspberrypi_01:/usr/local/lib/python2.7/dist-packages/gphoto2 $ ldd _camera.so
        linux-vdso.so.1 (0x7ed6d000)
        /usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76f81000)
        libgphoto2.so.6 => /usr/local/lib/libgphoto2.so.6 (0x76edf000)
        libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76e64000)
        libgphoto2_port.so.12 => /usr/local/lib/libgphoto2_port.so.12 (0x76e4b000)
        libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76e23000)
        libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76ce2000)
        /lib/ld-linux-armhf.so.3 (0x54b3e000)
        libltdl.so.7 => /usr/lib/arm-linux-gnueabihf/libltdl.so.7 (0x76cc9000)
        libexif.so.12 => /usr/lib/arm-linux-gnueabihf/libexif.so.12 (0x76c86000)
        libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76c73000)

Error from gphoto --summary:

pi@raspberrypi_01:/usr/local/bin $ gphoto2 --summary

*** Error ***
PTP I/O Error
*** Error (-7: 'I/O problem') ***

Error from python gphoto:

pi@raspberrypi_01:/usr/local/share/python-gphoto2/examples $ python camera-summary.py
WARNING: gphoto2: (gp_port_usb_close [libusb.c:325]) Invalid parameters: 'port && port->pl->dh' is NULL/FALSE.
WARNING: gphoto2: (camera_summary [library.c:5771]) 'ptp_getdeviceinfo (params, &pdi)' failed: 'PTP I/O Error' (0x02ff)
WARNING: gphoto2: (gp_context_error) PTP I/O Error
WARNING: gphoto2: (gp_camera_get_summary [gphoto2-camera.c:1244]) 'camera->functions->summary (camera, summary, context)' failed: -7
Traceback (most recent call last):
  File "camera-summary.py", line 59, in <module>
    sys.exit(main())
  File "camera-summary.py", line 33, in main
    text = gp.check_result(gp.gp_camera_get_summary(camera))
  File "/usr/local/lib/python2.7/dist-packages/gphoto2/result.py", line 159, in check_result
    raise gphoto2.GPhoto2Error(error)
gphoto2.GPhoto2Error: [-7] I/O problem