Coder Social home page Coder Social logo

python-gphoto2's Introduction

python-gphoto2 v2.5.1

python-gphoto2 is a comprehensive Python interface (or binding) to libgphoto2. It is built using SWIG to automatically generate the interface code. This gives direct access to nearly all the libgphoto2 functions, but sometimes in a rather un-Pythonic manner.

Other Python bindings to libgphoto2 are available: piggyphoto uses ctypes (included in standard Python installations) to interface to the library. The gphoto2 source tree includes some Python bindings which also use ctypes. gphoto2-cffi uses cffi.

Installation

Since python-gphoto2 version 2.3.1 "binary wheels" are provided for many Linux and MacOS computers. These include a recent version of the libgphoto2 libraries, and pre-built Python interface modules, which makes installation quick and easy. Use pip's --only-binary option to install one of these wheels:

$ pip3 install gphoto2 --user --only-binary :all:

If this fails it is most likely because none of the available wheels is compatible with your computer. In this case you must install some dependencies before installing python-gphoto2. See INSTALL.rst for more details.

Raspberry Pi

Binary wheels for the Raspberry Pi are available from piwheels. You need to install some system packages to use these:

$ sudo apt install libexif12 libgphoto2-6 libgphoto2-port12 libltdl7
$ pip3 install gphoto2 --user --only-binary :all:

Using python-gphoto2

The Python interface to libgphoto2 should allow you to do anything you could do in a C program. However, there are still bits missing and functions that cannot be called from Python. Let me know if you run into any problems.

The following paragraphs show how the Python interfaces differ from C. See the example programs for typical usage of the Python gphoto2 API.

"C" interface

These functions are as similar as possible to their libgphoto2 equivalents. Most of them return an error code which you must check.

Using SWIG to generate the Python interfaces automatically means that every function in libgphoto2 should be available to Python. You can show the documentation of a function with the pydoc command (or python -m pydoc if you installed gphoto2 with pip inside a virtual environment):

$ pydoc3 gphoto2.gp_camera_folder_list_files
Help on built-in function gp_camera_folder_list_files in gphoto2:

gphoto2.gp_camera_folder_list_files = gp_camera_folder_list_files(...)
    gp_camera_folder_list_files(camera, folder, context) -> int

    Parameters
    ----------
    camera: gphoto2.Camera
    folder: str
    context: gphoto2.Context (default=None)


    Lists the files in supplied `folder`.

    Parameters
    ----------
    * `camera` :
        a Camera
    * `folder` :
        a folder
    * `list` :
        a CameraList
    * `context` :
        a GPContext

    Returns
    -------
    a gphoto2 error code

    See also gphoto2.Camera.folder_list_files

The first part of this text is the function signature and parameter list generated by SWIG. (Note that context is optional - it's only needed if you need the callback functions that can be associated with a context.) The rest of the text is copied from the "doxygen" format documentation in the C source code. (The online API documentation shows how it is intended to look.) Note that this includes a list parameter that is not in the function signature. In C this is an "output" parameter, a concept that doesn't really exist in Python. The Python version of gp_camera_folder_list_files returns a sequence containing the integer error code and the list value.

Most of the libgphoto2 functions that use pointer parameters to return values in the C API have been adapted like this in the Python API. (Unfortunately I've not found a way to persuade SWIG to include this extra return value in the documentation. You should use pydoc to check the actual parameters expected by the Python function.)

For example, the C code:

#include "gphoto2.h"
int error;
Camera *camera;
error = gp_camera_new(&camera);
...
error = gp_camera_unref(camera);

has this Python equivalent:

import gphoto2 as gp
error, camera = gp.gp_camera_new()
...

Note that the gp_camera_unref() call is not needed. It is called automatically when the Python camera object is deleted.

Here is a complete example program (without any error checking):

import gphoto2 as gp
error, camera = gp.gp_camera_new()
error = gp.gp_camera_init(camera)
error, text = gp.gp_camera_get_summary(camera)
print('Summary')
print('=======')
print(text.text)
error = gp.gp_camera_exit(camera)

"Object oriented" interface

This is the preferred way to use libgphoto2 from Python. Most of the libgphoto2 functions have been added as methods of the appropriate GPhoto2 object. This allows GPhoto2 to be used in a more "Pythonic" style. For example, gp.gp_camera_init(camera) can be replaced by camera.init(). These methods also include error checking. If an error occurs they raise a Python GPhoto2Error exception.

The example program can be re-written as follows:

import gphoto2 as gp
camera = gp.Camera()
camera.init()
text = camera.get_summary()
print('Summary')
print('=======')
print(str(text))
camera.exit()

No additional error checking is required.

Error checking

Most of the libgphoto2 functions return an integer to indicate success or failure. The Python interface includes a check_result() function to check these values and raise a GPhoto2Error exception if an error occurs.

This function also removes the error code from lists such as that returned by gp_camera_new() in the example. Using this function the earlier example becomes:

import gphoto2 as gp
camera = gp.check_result(gp.gp_camera_new())
gp.check_result(gp.gp_camera_init(camera))
text = gp.check_result(gp.gp_camera_get_summary(camera))
print('Summary')
print('=======')
print(text.text)
gp.check_result(gp.gp_camera_exit(camera))

There may be some circumstances where you don't want an exception to be raised when some errors occur. You can "fine tune" the behaviour of the check_result() function by adjusting the error_severity variable:

import gphoto2 as gp
gp.error_severity[gp.GP_ERROR] = logging.WARNING
...

In this case a warning message will be logged (using Python's standard logging module) but no exception will be raised when a GP_ERROR error occurs. However, this is a "blanket" approach that treats all GP_ERROR errors the same. It is better to test for particular error conditions after particular operations, as described below.

The GPhoto2Error exception object has two attributes that may be useful in an exception handler. GPhoto2Error.code stores the integer error generated by the library function and GPhoto2Error.string stores the corresponding error message.

For example, to wait for a user to connect a camera you could do something like this:

import gphoto2 as gp
...
print('Please connect and switch on your camera')
while True:
    try:
        camera.init()
    except gp.GPhoto2Error as ex:
        if ex.code == gp.GP_ERROR_MODEL_NOT_FOUND:
            # no camera, try again in 2 seconds
            time.sleep(2)
            continue
        # some other error we can't handle here
        raise
    # operation completed successfully so exit loop
    break
# continue with rest of program
...

When just calling a single function like this, it's probably easier to test the error value directly instead of using Python exceptions:

import gphoto2 as gp
...
print('Please connect and switch on your camera')
while True:
    error = gp.gp_camera_init(camera)
    if error >= gp.GP_OK:
        # operation completed successfully so exit loop
        break
    if error != gp.GP_ERROR_MODEL_NOT_FOUND:
        # some other error we can't handle here
        raise gp.GPhoto2Error(error)
    # no camera, try again in 2 seconds
    time.sleep(2)
# continue with rest of program
...

Logging

The libgphoto2 library includes functions (such as gp_log()) to output messages from its various functions. These messages are mostly used for debugging purposes, and it can be helpful to see them when using libgphoto2 from Python. The Python interface includes a use_python_logging() function to connect libgphoto2 logging to the standard Python logging system. If you want to see the messages you should call use_python_logging() near the start of your program, as shown in the examples. In normal use you probably don't want to see these messages (libgphoto2 is rather verbose) so this could be controlled by a "verbose" or "debug" option in your application.

The libgphoto2 logging messages have four possible severity levels, each of which is mapped to a suitable Python logging severity. You can override this mapping by passing your own to use_python_logging():

import logging
import gphoto2 as gp
...
callback_obj = gp.check_result(gp.use_python_logging(mapping={
    gp.GP_LOG_ERROR   : logging.INFO,
    gp.GP_LOG_DEBUG   : logging.DEBUG,
    gp.GP_LOG_VERBOSE : logging.DEBUG - 3,
    gp.GP_LOG_DATA    : logging.DEBUG - 6}))
...

If you prefer to use your own logging system you can define a logging callback function in Python. The function must take 3 or 4 parameters: level, domain, string and an optional data. The data parameter allows you to pass some user data to your callback function (e.g. to log which thread an error occurred in): The callback function is installed with gp_log_add_func:

import gphoto2 as gp
...
def callback(level, domain, string, data=None):
    print('Callback: level =', level, ', domain =', domain, ', string =', string, 'data =', data)
...
callback_obj1 = gp.check_result(gp.gp_log_add_func(gp.GP_LOG_VERBOSE, callback))
callback_obj2 = gp.check_result(gp.gp_log_add_func(gp.GP_LOG_VERBOSE, callback, 123))
...

Deprecated functions

Some functions are intended for use by camera drivers and should not have been included in the Python interface. They will be removed in a future release. During testing you should run your software with Python's -Wd flag to show the warnings issued if you use any of the deprecated functions. Please contact me if you have reason to believe a deprecated function should not be removed.

What to do if you have a problem

If you find a problem in the Python gphoto2 interface (e.g. a segfault, a missing function, or a function without a usable return value) then please report it on the GitHub "issues" page (https://github.com/jim-easterbrook/python-gphoto2/issues) or email [email protected].

If your problem is more general, e.g. difficulty with capturing multiple images, then try doing what you want to do with the gphoto2 command line program. If the problem persists then it might be worth asking on the gphoto-user mailing list. Another reader of the mailing list may have the same camera model and already know what to do.

Notes on some gphoto2 functions

gp_camera_capture_preview / gp_camera_file_get

Before python-gphoto2 version 2.5.0 these functions (and their corresponding "object oriented" methods) always allocated and returned a new CameraFile object. Now you can pass in a previously allocated CameraFile for them to use. In this case it is not returned by the function.

If you need to use a Context value with these functions without passing in a CameraFile, then pass None in place of the CameraFile object.

gp_log_add_func / use_python_logging

Since python-gphoto2 version 2.0.0 these functions return a sequence containing an error code and an object storing details of the callback. The callback is automatically uninstalled when this object is deleted.

In earlier versions of python-gphoto2 these functions return an integer id that must be passed to gp_log_remove_func to uninstall the callback.

gp_context_set_idle_func / gp_context_set_progress_funcs / etc.

These functions are only usable since python-gphoto2 version 1.9.0. They return a Python object which your program must store until the callback(s) are no longer required. Deleting the returned object cancels the callback(s), so there is no need to do this yourself. See the context_with_callbacks.py example for a convenient way to do this.

gp_file_get_data_and_size / CameraFile.get_data_and_size

Since python-gphoto2 version 2.4.0 these functions return a Python memoryview object. Prior to that they returned a FileData object that supports the buffer protocol so its data can be made accessible to Python by using a memoryview object. This allows the data to be used without copying. See the copy-data.py example for typical usage.

Note that if the CameraFile object is deleted, or another function (such as gp_file_set_data_and_size or gp_file_open) changes the CameraFile's data, then this object will be invalidated and you will probably get a segmentation fault.

gp_file_set_data_and_size / CameraFile.set_data_and_size

Since python-gphoto2 version 2.1.0 these functions accept any bytes-like object. In earlier versions of python-gphoto2 these functions required a string and its length, and didn't work correctly anyway.

gp_camera_file_read / Camera.file_read

The buf parameter can be any Python object that exposes a writeable buffer interface. This allows you to read a file directly into a Python object without additional copying. See the copy-chunks.py example which uses memoryview to expose a bytearray.

gp_camera_wait_for_event / Camera.wait_for_event

These functions return both the event type and the event data. The data you get depends on the type. GP_EVENT_FILE_ADDED and GP_EVENT_FOLDER_ADDED events return a CameraFilePath, others return None or a text string.

Licence

python-gphoto2 - Python interface to libgphoto2
http://github.com/jim-easterbrook/python-gphoto2
Copyright (C) 2014-23 Jim Easterbrook [email protected]

python-gphoto2 is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

python-gphoto2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with python-gphoto2. If not, see <https://www.gnu.org/licenses/>.

python-gphoto2's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-gphoto2's Issues

Bug present in dev packages but OK in non-dev

Hi,
I'm trying to use libgphoto2 to control my Canon 1300d from python. When I update all packages using gphoto2-updater (and choosing "latest dev version") I get a 2.5.14 version of libgphoto2. I can call the camera and take several shots from the terminal, but when I try and use libgphoto2 in python, I get "no module name".
On the other hand, when I install libgphoto2-dev as suggested on issue #1 , I get 2.5.4 version installed. I don't get an error from python with that version, but I do get the error known with latest Canon cameras : after 1 photo taken the connection with the camera is somehow lost and I get the "no memory" error message.
Is this a known bug ? If it's just me, what can I do to solve this problem ?
Thanks in advance,
Mike

How to capture movie to stdout

Hi,

I'm trying to capture movie to stdout and pipe it to ffmpeg to stream video to another computer. I can do it from shell with the following command in shell :

gphoto2 --capture-movie --stdout | ffmpeg -i pipe:0 http://localhost:8080/feed1.ffm

As first step I tried to capture a movie :
gp.gp_camera_capture(camera, gp.GP_CAPTURE_VIDEO, context)

but i got the following error:

gphoto2.GPhoto2Error: [-6] Unsupported operation

Is capturing video not supported in python-gphoto2?

Build failed (archlinux)

Hi,

I'm the package maintainer for archlinux.


==> Making package: python-gphoto2 1.2.1-3 (sam. oct.  3 10:21:39 CEST 2015)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Found v1.2.1.tar.gz
==> Validating source files with sha256sums...
    v1.2.1.tar.gz ... Passed
==> Extracting sources...
  -> Extracting v1.2.1.tar.gz with bsdtar
==> Removing existing $pkgdir/ directory...
==> Starting build()...
running build_swig
swigging gphoto2 versions ['2.5']
swig -python -nodefaultctor -O -Wextra -Werror -builtin -py3 -DGPHOTO2_25 -outdir src/swig-gp2.5 -I/usr/include -o src/swig-gp2.5/gphoto2_abilities_list_wrap.c src/gphoto2/gphoto2_abilities_list.i
swig -python -nodefaultctor -O -Wextra -Werror -builtin -py3 -DGPHOTO2_25 -outdir src/swig-gp2.5 -I/usr/include -o src/swig-gp2.5/gphoto2_camera_wrap.c src/gphoto2/gphoto2_camera.i
swig -python -nodefaultctor -O -Wextra -Werror -builtin -py3 -DGPHOTO2_25 -outdir src/swig-gp2.5 -I/usr/include -o src/swig-gp2.5/gphoto2_context_wrap.c src/gphoto2/gphoto2_context.i
swig -python -nodefaultctor -O -Wextra -Werror -builtin -py3 -DGPHOTO2_25 -outdir src/swig-gp2.5 -I/usr/include -o src/swig-gp2.5/gphoto2_file_wrap.c src/gphoto2/gphoto2_file.i
swig -python -nodefaultctor -O -Wextra -Werror -builtin -py3 -DGPHOTO2_25 -outdir src/swig-gp2.5 -I/usr/include -o src/swig-gp2.5/gphoto2_filesys_wrap.c src/gphoto2/gphoto2_filesys.i
swig -python -nodefaultctor -O -Wextra -Werror -builtin -py3 -DGPHOTO2_25 -outdir src/swig-gp2.5 -I/usr/include -o src/swig-gp2.5/gphoto2_list_wrap.c src/gphoto2/gphoto2_list.i
swig -python -nodefaultctor -O -Wextra -Werror -builtin -py3 -DGPHOTO2_25 -outdir src/swig-gp2.5 -I/usr/include -o src/swig-gp2.5/gphoto2_port_wrap.c src/gphoto2/gphoto2_port.i
swig -python -nodefaultctor -O -Wextra -Werror -builtin -py3 -DGPHOTO2_25 -outdir src/swig-gp2.5 -I/usr/include -o src/swig-gp2.5/gphoto2_port_info_list_wrap.c src/gphoto2/gphoto2_port_info_list.i
swig -python -nodefaultctor -O -Wextra -Werror -builtin -py3 -DGPHOTO2_25 -outdir src/swig-gp2.5 -I/usr/include -o src/swig-gp2.5/gphoto2_port_log_wrap.c src/gphoto2/gphoto2_port_log.i
swig -python -nodefaultctor -O -Wextra -Werror -builtin -py3 -DGPHOTO2_25 -outdir src/swig-gp2.5 -I/usr/include -o src/swig-gp2.5/gphoto2_result_wrap.c src/gphoto2/gphoto2_result.i
swig -python -nodefaultctor -O -Wextra -Werror -builtin -py3 -DGPHOTO2_25 -outdir src/swig-gp2.5 -I/usr/include -o src/swig-gp2.5/gphoto2_version_wrap.c src/gphoto2/gphoto2_version.i
swig -python -nodefaultctor -O -Wextra -Werror -builtin -py3 -DGPHOTO2_25 -outdir src/swig-gp2.5 -I/usr/include -o src/swig-gp2.5/gphoto2_widget_wrap.c src/gphoto2/gphoto2_widget.i
running build
running build_py
copying src/swig-gp2.5/gphoto2_context.py -> build/lib.linux-x86_64-3.5/gphoto2
copying src/swig-gp2.5/gphoto2_file.py -> build/lib.linux-x86_64-3.5/gphoto2
copying src/swig-gp2.5/gphoto2_camera.py -> build/lib.linux-x86_64-3.5/gphoto2
copying src/swig-gp2.5/__init__.py -> build/lib.linux-x86_64-3.5/gphoto2
copying src/swig-gp2.5/gphoto2_result.py -> build/lib.linux-x86_64-3.5/gphoto2
copying src/swig-gp2.5/gphoto2_abilities_list.py -> build/lib.linux-x86_64-3.5/gphoto2
copying src/swig-gp2.5/gphoto2_widget.py -> build/lib.linux-x86_64-3.5/gphoto2
copying src/swig-gp2.5/gphoto2_port_info_list.py -> build/lib.linux-x86_64-3.5/gphoto2
copying src/swig-gp2.5/gphoto2_port.py -> build/lib.linux-x86_64-3.5/gphoto2
copying src/swig-gp2.5/gphoto2_port_log.py -> build/lib.linux-x86_64-3.5/gphoto2
copying src/swig-gp2.5/gphoto2_filesys.py -> build/lib.linux-x86_64-3.5/gphoto2
copying src/swig-gp2.5/gphoto2_list.py -> build/lib.linux-x86_64-3.5/gphoto2
copying src/swig-gp2.5/gphoto2_version.py -> build/lib.linux-x86_64-3.5/gphoto2
running build_ext
building '_gphoto2_abilities_list' extension
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include -I/usr/include/python3.5m -c src/swig-gp2.5/gphoto2_abilities_list_wrap.c -o build/temp.linux-x86_64-3.5/src/swig-gp2.5/gphoto2_abilities_list_wrap.o -O3 -Wno-unused-variable -Wno-strict-prototypes -Werror
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5567:5: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     (binaryfunc) 0,                           /* nb_add */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5567:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async.am_await')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5568:5: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     (binaryfunc) 0,                           /* nb_subtract */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5568:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async.am_aiter')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5569:5: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     (binaryfunc) 0,                           /* nb_multiply */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5569:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async.am_anext')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5573:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_remainder */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5573:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5574:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_divmod */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5574:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5575:5: error: excess elements in struct initializer [-Werror]
     (ternaryfunc) 0,                          /* nb_power */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5575:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5576:5: error: excess elements in struct initializer [-Werror]
     (unaryfunc) 0,                            /* nb_negative */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5576:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5577:5: error: excess elements in struct initializer [-Werror]
     (unaryfunc) 0,                            /* nb_positive */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5577:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5578:5: error: excess elements in struct initializer [-Werror]
     (unaryfunc) 0,                            /* nb_absolute */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5578:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5579:5: error: excess elements in struct initializer [-Werror]
     (inquiry) 0,                              /* nb_nonzero */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5579:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5580:5: error: excess elements in struct initializer [-Werror]
     (unaryfunc) 0,                            /* nb_invert */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5580:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5581:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_lshift */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5581:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5582:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_rshift */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5582:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5583:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_and */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5583:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5584:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_xor */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5584:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5585:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_or */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5585:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5589:5: error: excess elements in struct initializer [-Werror]
     (unaryfunc) 0,                            /* nb_int */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5589:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5591:5: error: excess elements in struct initializer [-Werror]
     (void*) 0,                                /* nb_reserved */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5591:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5595:5: error: excess elements in struct initializer [-Werror]
     (unaryfunc) 0,                            /* nb_float */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5595:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5600:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_add */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5600:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5601:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_subtract */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5601:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5602:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_multiply */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5602:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5606:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_remainder */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5606:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5607:5: error: excess elements in struct initializer [-Werror]
     (ternaryfunc) 0,                          /* nb_inplace_power */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5607:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5608:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_lshift */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5608:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5609:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_rshift */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5609:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5610:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_and */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5610:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5611:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_xor */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5611:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5612:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_or */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5612:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5613:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_floor_divide */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5613:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5614:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_true_divide */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5614:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5615:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_floor_divide */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5615:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5616:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_true_divide */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5616:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5618:5: error: excess elements in struct initializer [-Werror]
     (unaryfunc) 0,                            /* nb_index */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5618:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5622:5: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     (lenfunc) 0,                              /* mp_length */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5622:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_number.nb_add')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5624:5: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     (objobjargproc) 0,                        /* mp_ass_subscript */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5624:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_number.nb_multiply')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5629:5: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     (ssizeargfunc) 0,                         /* sq_repeat */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5629:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_mapping.mp_ass_subscript')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5630:5: error: excess elements in struct initializer [-Werror]
     (ssizeargfunc) (ssizeargfunc) _wrap_CameraAbilitiesList___getitem___closure, /* sq_item */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5630:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_mapping')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5632:5: error: excess elements in struct initializer [-Werror]
     (void*) 0,                                /* was_sq_slice */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5632:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_mapping')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5636:5: error: excess elements in struct initializer [-Werror]
     (ssizeobjargproc) 0,                      /* sq_ass_item */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5636:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_mapping')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5638:5: error: excess elements in struct initializer [-Werror]
     (void*) 0,                                /* was_sq_ass_slice */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5638:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_mapping')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5642:5: error: excess elements in struct initializer [-Werror]
     (objobjproc) 0,                           /* sq_contains */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5642:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_mapping')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5643:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* sq_inplace_concat */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5643:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_mapping')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5644:5: error: excess elements in struct initializer [-Werror]
     (ssizeargfunc) 0,                         /* sq_inplace_repeat */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5644:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_mapping')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5654:5: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     (getbufferproc) 0,                        /* bf_getbuffer */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5654:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_sequence.sq_length')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5655:5: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     (releasebufferproc) 0,                    /* bf_releasebuffer */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5655:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_sequence.sq_concat')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5658:5: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     (PyObject*) 0,                            /* ht_name */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5658:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_buffer.bf_getbuffer')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5659:5: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     (PyObject*) 0,                            /* ht_slots */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5659:5: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type.as_buffer.bf_releasebuffer')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5501:68: error: missing braces around initializer [-Werror=missing-braces]
 static PyHeapTypeObject SwigPyBuiltin___CameraAbilitiesList_type = {
                                                                    ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5501:68: note: (near initialization for 'SwigPyBuiltin___CameraAbilitiesList_type')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5822:5: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     (binaryfunc) 0,                           /* nb_add */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5822:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async.am_await')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5823:5: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     (binaryfunc) 0,                           /* nb_subtract */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5823:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async.am_aiter')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5824:5: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     (binaryfunc) 0,                           /* nb_multiply */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5824:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async.am_anext')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5828:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_remainder */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5828:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5829:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_divmod */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5829:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5830:5: error: excess elements in struct initializer [-Werror]
     (ternaryfunc) 0,                          /* nb_power */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5830:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5831:5: error: excess elements in struct initializer [-Werror]
     (unaryfunc) 0,                            /* nb_negative */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5831:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5832:5: error: excess elements in struct initializer [-Werror]
     (unaryfunc) 0,                            /* nb_positive */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5832:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5833:5: error: excess elements in struct initializer [-Werror]
     (unaryfunc) 0,                            /* nb_absolute */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5833:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5834:5: error: excess elements in struct initializer [-Werror]
     (inquiry) 0,                              /* nb_nonzero */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5834:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5835:5: error: excess elements in struct initializer [-Werror]
     (unaryfunc) 0,                            /* nb_invert */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5835:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5836:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_lshift */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5836:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5837:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_rshift */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5837:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5838:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_and */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5838:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5839:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_xor */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5839:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5840:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_or */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5840:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5844:5: error: excess elements in struct initializer [-Werror]
     (unaryfunc) 0,                            /* nb_int */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5844:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5846:5: error: excess elements in struct initializer [-Werror]
     (void*) 0,                                /* nb_reserved */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5846:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5850:5: error: excess elements in struct initializer [-Werror]
     (unaryfunc) 0,                            /* nb_float */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5850:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5855:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_add */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5855:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5856:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_subtract */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5856:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5857:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_multiply */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5857:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5861:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_remainder */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5861:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5862:5: error: excess elements in struct initializer [-Werror]
     (ternaryfunc) 0,                          /* nb_inplace_power */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5862:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5863:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_lshift */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5863:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5864:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_rshift */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5864:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5865:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_and */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5865:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5866:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_xor */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5866:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5867:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_or */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5867:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5868:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_floor_divide */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5868:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5869:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_true_divide */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5869:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5870:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_floor_divide */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5870:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5871:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* nb_inplace_true_divide */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5871:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5873:5: error: excess elements in struct initializer [-Werror]
     (unaryfunc) 0,                            /* nb_index */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5873:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_async')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5877:5: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     (lenfunc) 0,                              /* mp_length */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5877:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_number.nb_add')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5879:5: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     (objobjargproc) 0,                        /* mp_ass_subscript */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5879:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_number.nb_multiply')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5884:5: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     (ssizeargfunc) 0,                         /* sq_repeat */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5884:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_mapping.mp_ass_subscript')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5885:5: error: excess elements in struct initializer [-Werror]
     (ssizeargfunc) 0,                         /* sq_item */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5885:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_mapping')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5887:5: error: excess elements in struct initializer [-Werror]
     (void*) 0,                                /* was_sq_slice */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5887:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_mapping')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5891:5: error: excess elements in struct initializer [-Werror]
     (ssizeobjargproc) 0,                      /* sq_ass_item */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5891:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_mapping')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5893:5: error: excess elements in struct initializer [-Werror]
     (void*) 0,                                /* was_sq_ass_slice */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5893:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_mapping')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5897:5: error: excess elements in struct initializer [-Werror]
     (objobjproc) 0,                           /* sq_contains */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5897:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_mapping')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5898:5: error: excess elements in struct initializer [-Werror]
     (binaryfunc) 0,                           /* sq_inplace_concat */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5898:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_mapping')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5899:5: error: excess elements in struct initializer [-Werror]
     (ssizeargfunc) 0,                         /* sq_inplace_repeat */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5899:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_mapping')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5909:5: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     (getbufferproc) 0,                        /* bf_getbuffer */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5909:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_sequence.sq_length')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5910:5: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     (releasebufferproc) 0,                    /* bf_releasebuffer */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5910:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_sequence.sq_concat')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5913:5: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     (PyObject*) 0,                            /* ht_name */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5913:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_buffer.bf_getbuffer')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5914:5: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     (PyObject*) 0,                            /* ht_slots */
     ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5914:5: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type.as_buffer.bf_releasebuffer')
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5756:63: error: missing braces around initializer [-Werror=missing-braces]
 static PyHeapTypeObject SwigPyBuiltin__CameraAbilities_type = {
                                                               ^
src/swig-gp2.5/gphoto2_abilities_list_wrap.c:5756:63: note: (near initialization for 'SwigPyBuiltin__CameraAbilities_type')
cc1: all warnings being treated as errors
error: command 'gcc' failed with exit status 1
==> ERROR: A failure occurred in build().
    Aborting...



How is gp_camera_wait_for_event working ?

I want to wait for a GP_EVENT_FILE_ADDED event. Here is my code:

gp.check_result(gp.gp_camera_wait_for_event(camera, gp.GP_EVENT_FILE_ADDED, context))

I would expect the function to wait until the event happen but instead it returns immediately (0, None)
My workaround is to create a while loop like this:

while True:
    event_type, data = gp.check_result(gp.gp_camera_wait_for_event(camera, gp.GP_EVENT_FILE_ADDED, context))
    if event_type == gp.GP_EVENT_FILE_ADDED:
        camera_file_path = data
        return camera_file_path
    time.sleep(0.1)

which is working but does not feel right. Any help would be greatly appreciated.

Error in capture-image

Installing python-gphoto2 on a fresh latest Raspian Stretch distro and Pi ZeroW.
gphoto2 v 2.5.15, but when I call capture-image on a Nikon camera after setting target to memory card I got

Capturing image
Camera file path: /store_00010001/DCIM/167ND700/_NIC0875.JPG
Copying image to /tmp/_NIC0875.JPG
Traceback (most recent call last):
  File "capture-image.py", line 49, in <module>
    sys.exit(main())
  File "capture-image.py", line 44, in main
    subprocess.call(['xdg-open', target])
  File "/usr/lib/python2.7/subprocess.py", line 168, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 390, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1024, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Changing storage loc returns warnings:

python set-capture-target.py 1
WARNING: gphoto2: (_get_config [config.c:7471]) Type of property 'ISO Auto Hi Limit' expected: 0x0001 got: 0x0002
WARNING: gphoto2: (_get_config [config.c:7471]) Type of property 'Active D-Lighting' expected: 0x0001 got: 0x0002
WARNING: gphoto2: (_get_config [config.c:7471]) Type of property 'High ISO Noise Reduction' expected: 0x0001 got: 0x0002
WARNING: gphoto2: (_get_config [config.c:7471]) Type of property 'Flash Exposure Compensation' expected: 0x0002 got: 0x0001
WARNING: gphoto2: (ptp_usb_event [usb.c:530]) Reading PTP event failed: Timeout reading from or writing to the port (-10)

Target internal RAM returns nearly the same:

WARNING: gphoto2: (ptp_usb_getresp [usb.c:465]) PTP_OC 0x1002 receiving resp failed: PTP Session Already Opened (0x201e)
WARNING: gphoto2: (camera_init [library.c:7729]) 'ptp_opensession (params, sessionid)' failed: PTP Session Already Opened (0x201e)
Capturing image
WARNING: gphoto2: (camera_nikon_capture [library.c:3093]) Parentobject of newobject 0x2b000005 is 0x0 now?
Camera file path: //capt0000.jpg
Copying image to /tmp/capt0000.jpg
Traceback (most recent call last):
  File "capture-image.py", line 49, in <module>
    sys.exit(main())
  File "capture-image.py", line 44, in main
    subprocess.call(['xdg-open', target])
  File "/usr/lib/python2.7/subprocess.py", line 168, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 390, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1024, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Calling on gphoto2 cli returns no errors:

gphoto2 --capture-image
New file is in location /store_00010001/DCIM/167ND700/_NIC0876.JPG on the camera

But in all cases camera is storing images on mem card and I can see it later on display.

What do then all the errors and warnings mean? And why its mentioned "Copying image to /tmp/"?

Best regards,
Nic

Examples not up-to-date

It seems a lot of functions now require context but none was used in examples (Specifically, the ones I looked at, choose-camera and capture).

For example, gp.Camera().init() needs a camera context and

When I try to use the example an error would occur.

problem calling "setup.py build"

Hi,
I get the following error-message after calling "python setup.py build".

Traceback (most recent call last):
File "setup.py", line 31, in
gphoto2_version = str(subprocess.check_output(['gphoto2-config', '--version']))
File "/usr/lib/python2.7/subprocess.py", line 566, in check_output
process = Popen(stdout=PIPE, _popenargs, *_kwargs)
File "/usr/lib/python2.7/subprocess.py", line 709, in init
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1326, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

The problem is that i can actually find the file using "find"-command.
Thus the file does exist in the directory.

It's located in: /usr/lib/bin/gphoto2-config

Best regards
mk770

Cannot install on Mac

Awesome package, I've been using it for a couple months on Ubuntu. Unfortunately, I can't seem to get it working on Mac. I've tried

sudo pip install -V gphoto2

building from swig

and building from the tar

All fail with the same error:

Traceback (most recent call last):
File "setup.py", line 35, in
universal_newlines=True).split('.')[:2])
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 567, in check_output
process = Popen(stdout=PIPE, _popenargs, *_kwargs)
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 711, in init
errread, errwrite)
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

I'm not sure what is causing this as I do have gphoto2 installed:
$ gphoto2
Usage: gphoto2 [-?qvalLnPTDR] [-?|--help] [--usage] [--debug]....

Any help would be awesome!

Capture multiple RAW+JPG and download the JPGs

Hi,
I'm trying to use this library for camera control in a Raspberry Pi-controlled timelapse slider.

My setup is:
Raspberry Pi Zero W, running Raspbian Stretch
libgphoto2/2.5.15
python-gphoto2-1.8.2
Canon EOS 6D

I need to shoot in "RAW+JPG" mode and to download only the JPG to the RPi (for bulb ramping). Since camera.capture returns the file_path of the RAW file (extension .CR2), I replace the extension with ".JPG" to call camera.file_get. However, this only works on the first shot, while the second call results in a gphoto2.GPhoto2Error: [-108] File not found, whereas the file actually exists in the same path.
If I try to get the .CR2 file instead it works correctly.

Code to reproduce the behavior:

import gphoto2 as gp
import logging
import os

#Logging
logging.basicConfig(format='%(levelname)s: %(name)s: %(message)s', level=logging.WARNING)
gp.check_result(gp.use_python_logging())

#Camera init
camera = gp.Camera()
camera.init()

for i in range(2):
    #Capture image RAW+JPG
    file_path=camera.capture(gp.GP_CAPTURE_IMAGE)
    print("Captured " + file_path.folder + "/" + file_path.name)
    #Save JPG to Raspi /tmp
    file_path_jpg = file_path.name.replace("CR2", "JPG")
    camera_file = camera.file_get(file_path.folder,file_path_jpg,gp.GP_FILE_TYPE_NORMAL)
    target = os.path.join("/tmp",file_path_jpg)
    print("Copying to: " + target)
    gp.gp_file_save(camera_file, target)

camera.exit()

And the resulting output:

WARNING: gphoto2: (ptp_list_folder_eos [library.c:7342]) storage 0xffffffff, but handle 0x00000000?
Captured /store_00020001/DCIM/100CANON/IMG_8849.CR2
Copying to: /tmp/IMG_8849.JPG
Captured /store_00020001/DCIM/100CANON/IMG_8850.CR2
WARNING: gphoto2: (gp_camera_file_get [gphoto2-camera.c:1693]) 'gp_filesystem_get_file (camera->fs, folder, file, type, camera_file, context)' failed: -108
Traceback (most recent call last):
  File "minimal.py", line 19, in <module>
    camera_file = camera.file_get(file_path.folder,file_path_jpg,gp.GP_FILE_TYPE_NORMAL)
gphoto2.GPhoto2Error: [-108] File not found

The only solution I have found at the moment is to call camera.exit() after each shot, but it does not seem ideal.

Thanks!
Alessio

Lots of warnings when using gphoto2 from Python

Hi! I'm getting a lot of these warnings when using python-gphoto2.

(gp_port_usb_close [libusb.c:325]) Invalid parameters: 'port && port->pl->dh' is NULL/FALSE.
(gp_port_usb_close [libusb.c:325]) Invalid parameters: 'port && port->pl->dh' is NULL/FALSE.
(ptp_usb_event [usb.c:530]) Reading PTP event failed: Timeout reading from or writing to the port (-10)
(ptp_usb_event [usb.c:530]) Reading PTP event failed: Timeout reading from or writing to the port (-10)
(camera_sony_capture [library.c:3800]) no object found during event polling. try the 0xffffc001 object id
(gp_port_usb_close [libusb.c:325]) Invalid parameters: 'port && port->pl->dh' is NULL/FALSE.

I have no idea where I should start looking for the source of these errors/warnings. Are these related to the Python bindings or could it be that the driver in libgphoto2 does not support my camera very well? If that's the case, is there a way to mute these warnings?

Thanks!

capture-image and get-files not working

Hi Jim, I am working with python-gphoto2 on a Raspberry Pi with a Nikon D7200 camera.
I can perform all functions I have tried ok but having trouble getting files from camera.
Neither the capture-image or get-files works. The camera SD-card access LED goes on but the program exits when it gets to the
Camera_file = gp.check_result(gp.gp_camera_file_get(
camera, file_path.folder, file_path.name,
gp.GP_FILE_TYPE_NORMAL, context))
line. I then have to turn camera off and back on to talk to it again.
I can get files and capture images from gphoto2, v2.5.10 with libgphoto2 2.5.4.
Any ideas?
Thanks,
Chris

How to capture to a file with a predetermined name

Let's say I am iterating between files 1-100, and i want to name them photo_001.jpg, photo_002.jpg what can I do to capture an image with a name I'm giving it, like the equivalent function on command line? I'm having a hard time finding something similar in the examples?

Multithreading camera settings change

I have several cameras connected to one computer, and these cameras (Sony A5000) are very slow to change their settings and python_gphoto2 does it unthreaded so settings only change on one camera at a time, takes a while.

I have recompiled with gp_camera_set_config and gp_camera_set_single_config as threaded and it works fine with the Sonys at least. I can make a pull request if this can be merged in, unless there's a reason not to?

Copying files to camera

i have captured and downloaded images from the camera successfully thanks to your python library for Pi, now i want to copy the photos from the raspberry to the camera again, the application that i am working is geotagging images, so i take the picture, download to /pi/ add exif data and i want to move back to the camera, i have checked the functions but i dont see a specific function that do it.

ImportError: No module named _camera

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.

Change from qt4 to qt5

Probably not that important, but when setting up the required libraries to run the GUI examples I noticed on the Python page that qt4 is no longer supported, so I only loaded qt5.

To make the camera-config-gui.py and camera-config-gui-oo.py examples to work, I changed the imports to the following:
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtCore import Qt
...and changed all references of QtGui to QtWidgets.

This seems to have done the trick.

Tried to compile on Raspberry PI

Hi Jim,
I love that someone finally is working on a real wrapper for gphoto2 for python.
I tried to compile on a raspberry PI as I am starting a series of time lapse scripts and I got the following, my days of C are a bit behind me so not sure if I am missing a dev or if its something else below is the output of what I ran:

*running build
running build_py
copying source/gphoto2_camera.py -> build/lib.linux-armv6l-2.7/gphoto2
copying source/gphoto2_abilities_list.py -> build/lib.linux-armv6l-2.7/gphoto2
running build_ext
building '_gphoto2_camera' extension
swigging source/gphoto2_camera.i to source/gphoto2_camera_wrap.c
swig -python -I/usr/include -builtin -O -Wall -o source/gphoto2_camera_wrap.c source/gphoto2_camera.i
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c source/gphoto2_camera_wrap.c -o build/temp.linux-armv6l-2.7/source/gphoto2_camera_wrap.o -O3 -Wno-unused-variable
source/gphoto2_camera_wrap.c: In function ‘_wrap_gp_camera_get_port_info’:
source/gphoto2_camera_wrap.c:5536:5: error: incompatible type for argument 2 of ‘SWIG_Python_NewPointerObj’
source/gphoto2_camera_wrap.c:2547:1: note: expected ‘void ’ but argument is of type ‘GPPortInfo’
error: command 'gcc' failed with exit status 1

Thanks for the help

Cheers

Fred

pip install fails on OS X

$ pip install -v gphoto2

...

  Looking up "https://pypi.python.org/packages/f8/6b/90b671ab3805f939d5b2ba9428472d18e472a4efc93f9158c4d0f24ef25e/gphoto2-1.8.1.tar.gz" in the cache
  Current age based on date: 706
  Freshness lifetime from max-age: 31557600
  The response is "fresh", returning cached response
  31557600 > 706
  Using cached gphoto2-1.8.1.tar.gz
  Downloading from URL https://pypi.python.org/packages/f8/6b/90b671ab3805f939d5b2ba9428472d18e472a4efc93f9158c4d0f24ef25e/gphoto2-1.8.1.tar.gz#md5=9dbceae88aaae398a9bceed35b5cb2ed (from https://pypi.python.org/simple/gphoto2/)
  Running setup.py (path:/private/var/folders/m2/lx07_jr55nx7_5nzcs0ftk6r0000gn/T/pip-build-rgDNkp/gphoto2/setup.py) egg_info for package gphoto2
    Running command python setup.py egg_info
    ERROR: command "pkg-config --modversion libgphoto2" failed
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/m2/lx07_jr55nx7_5nzcs0ftk6r0000gn/T/pip-build-rgDNkp/gphoto2/setup.py", line 38, in <module>
        cmd, stderr=FNULL, universal_newlines=True).split('.')
      File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 573, in check_output
        raise CalledProcessError(retcode, cmd, output=output)
    subprocess.CalledProcessError: Command '['pkg-config', '--modversion', 'libgphoto2']' returned non-zero exit status 1
Cleaning up...
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/m2/lx07_jr55nx7_5nzcs0ftk6r0000gn/T/pip-build-rgDNkp/gphoto2/
Exception information:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 335, in run
    wb.build(autobuilding=True)
  File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 634, in _prepare_file
    abstract_dist.prep_for_dist()
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 129, in prep_for_dist
    self.req_to_install.run_egg_info()
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 439, in run_egg_info
    command_desc='python setup.py egg_info')
  File "/usr/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 707, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/m2/lx07_jr55nx7_5nzcs0ftk6r0000gn/T/pip-build-rgDNkp/gphoto2/

When I try running that command, I get this:

$ pkg-config --modversion libgphoto2
Package libgphoto2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libgphoto2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libgphoto2' found

This is on OS X 13.1. Any idea why pkg-config doesn't know about the package?

Thanks!

Installation issues - can't find libgphoto2.pc

Hi,

I am trying to installing python-gphoto2 on an Ubuntu 16.04LTS system. I have previously installed gphoto2 v 2.5.9 via apt-get and it is working fine. When setup.py runs it complains that it cannot find libgphoto2.pc and terminates with multiple errors (abbreviated output from a pip3 installation is below - errors are at the end). I can find libgphoto2.pc nowhere on my machine - it looks like apt-get did not install it.

I am relatively new to this so apologies if this is a simplistic question - how do I fix this? I have found other users with the same issue elsewhere on the web with the same issue but no solution. Within the tar file for libgphoto2 there is a libgphoto2.pc.in file. Can I just rename it, put it in the same directory as other .pc files, add that directory to the PKG_CONFIG_PATH environment variable and it should work?

Thanks,

Gavin

gavin@gavin-ThinkPad-T430u:~$ sudo -H pip3 install -v gphoto2
Collecting gphoto2
1 location(s) to search for versions of gphoto2:

REMOVED MANY OF THE FOUND LINKS FOR BREVITY

https://pypi.python.org/packages/ff/6f/0292c9e794aa25d54ca565c459daaafe7f886cfc35cfd18739bb8b32c07a/gphoto2-1.4.0.zip#md5=7fc27c46e8acf623453da90ca32e8892 (from https://pypi.python.org/simple/gphoto2/), version: 1.4.0
Using version 1.7.0 (newest of versions: 0.3.2, 0.3.3, 0.4.0, 0.5.0, 0.5.1, 0.5.2, 0.6.0, 0.7.0, 0.7.1, 0.8.0, 0.9.0, 0.9.1, 0.10.0, 0.10.1, 0.10.2, 0.11.0, 0.11.1, 0.11.2, 1.0.0, 1.1.0, 1.2.0, 1.2.1, 1.2.2, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.6.0, 1.7.0)
Looking up "https://pypi.python.org/packages/d9/05/de56a7266fc5b61c38a3aa5caa03a71dcd9c23d827b4638b96912d4511fb/gphoto2-1.7.0.tar.gz" in the cache
No cache entry available
"GET /packages/d9/05/de56a7266fc5b61c38a3aa5caa03a71dcd9c23d827b4638b96912d4511fb/gphoto2-1.7.0.tar.gz HTTP/1.1" 200 6831640
Downloading gphoto2-1.7.0.tar.gz (6.8MB)
Downloading from URL https://pypi.python.org/packages/d9/05/de56a7266fc5b61c38a3aa5caa03a71dcd9c23d827b4638b96912d4511fb/gphoto2-1.7.0.tar.gz#md5=4874826d5f6e36d526686344735a8555 (from https://pypi.python.org/simple/gphoto2/)
99% |████████████████████████████████| 6.8MB 9.4MB/s eta 0:00:01 Updating cache with response from "https://pypi.python.org/packages/d9/05/de56a7266fc5b61c38a3aa5caa03a71dcd9c23d827b4638b96912d4511fb/gphoto2-1.7.0.tar.gz"
Caching due to etag
100% |████████████████████████████████| 6.8MB 202kB/s
Running setup.py (path:/tmp/pip-build-gtemulbk/gphoto2/setup.py) egg_info for package gphoto2
Running** command python setup.py egg_info
Package libgphoto2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libgphoto2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libgphoto2' found
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-gtemulbk/gphoto2/setup.py", line 37, in
cmd, universal_newlines=True).split('.')
File "/usr/lib/python3.5/subprocess.py", line 626, in check_output
kwargs).stdout
File "/usr/lib/python3.5/subprocess.py", line 708, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['pkg-config', '--modversion', 'libgphoto2']' returned non-zero exit status 1
Cleaning up...
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-gtemulbk/gphoto2/
Exception information:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python3.5/dist-packages/pip/commands/install.py", line 335, in run
wb.build(autobuilding=True)
File "/usr/local/lib/python3.5/dist-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/local/lib/python3.5/dist-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/local/lib/python3.5/dist-packages/pip/req/req_set.py", line 634, in _prepare_file
abstract_dist.prep_for_dist()
File "/usr/local/lib/python3.5/dist-packages/pip/req/req_set.py", line 129, in prep_for_dist
self.req_to_install.run_egg_info()
File "/usr/local/lib/python3.5/dist-packages/pip/req/req_install.py", line 439, in run_egg_info
command_desc='python setup.py egg_info')
File "/usr/local/lib/python3.5/dist-packages/pip/utils/init.py", line 707, in call_subprocess
% (command_desc, proc.returncode, cwd))
pip.exceptions.InstallationError: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-gtemulbk/gphoto2/
Looking up "https://pypi.python.org/pypi/pip/json" in the cache
No cache entry available
Starting new HTTPS connection (1): pypi.python.org
"GET /pypi/pip/json HTTP/1.1" 200 72983
Updating cache with response from "https://pypi.python.org/pypi/pip/json"
Caching b/c date exists and max-age > 0**

PIP install on Mac OS X

Hi
i want to install it over PIP but i get an error

ld: library not found for -lexif

clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: command '/usr/bin/clang' failed with exit status 1

----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/3.4/bin/python3 -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-i1ba25_o/gphoto2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-5bbvwecu-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-i1ba25_o/gphoto2

Trouble with Nikon D700

Hi,
I try to make a simple code but it's not working for now ...

My code is this :
context = gp.Context()
camera = gp.Camera()
camera.init(context)
camera_file = gp.check_result(gp.gp_camera_capture_preview(camera, context))
file_data = gp.check_result(gp.gp_file_get_data_and_size(camera_file))

display image

data = memoryview(file_data)
print(type(data), len(data))
print(data[:10].tolist())
image = Image.open(io.BytesIO(file_data))
image.show()
gp.check_result(gp.gp_camera_exit(camera, context))
context2 = gp.Context()
camera2 = gp.Camera()
camera2.init(context2)
print('Capturing preview image 2')
camera_file2 = gp.gp_camera_capture_preview(camera2, context2)
file_data2 = gp.gp_file_get_data_and_size(camera_file2[1])

display image

data2 = memoryview(file_data2[1])
print(type(data2), len(data2))
print(data2[:10].tolist())

image2 = Image.open(io.BytesIO(file_data2[1]))

image2.show()

gp.gp_camera_exit(camera2, context2)
return 0

But only 1 capture was made and I have the following error :
WARNING: gphoto2: (gp_port_usb_close [libusb.c:321]) Invalid parameters: 'port && port->pl->dh' is NULL/FALSE.
Checking camera config
Capturing preview image
WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x90c8 receiving resp failed: PTP Device Busy (0x2019)
WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x90c8 receiving resp failed: PTP Device Busy (0x2019)
WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x90c8 receiving resp failed: PTP Device Busy (0x2019)
WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x90c8 receiving resp failed: PTP Device Busy (0x2019)
WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x90c8 receiving resp failed: PTP Device Busy (0x2019)
<type 'memoryview'> 15147
[255, 216, 255, 219, 0, 132, 0, 4, 6, 6]
WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x90c2 receiving resp failed: Change Camera Mode Failed (0xa003)
WARNING: gphoto2: (gp_port_usb_close [libusb.c:321]) Invalid parameters: 'port && port->pl->dh' is NULL/FALSE.
Capturing preview image 2
WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x9201 receiving resp failed: PTP Device Busy (0x2019)
WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x9203 receiving resp failed: Not in Liveview (0xa00b)
WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x9201 receiving resp failed: PTP Device Busy (0x2019)
WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x9203 receiving resp failed: Not in Liveview (0xa00b)

What I am doing wrong ?
Can you help me ?

Thank you !

undefined symbol: gp_camera_get_single_config

Version 1.5.1 of the Python interface attempts to be compatible with old versions of libgphoto2 that don't have the gp_camera_get_single_config function as well as new versions that do. However this is failing on some installations producing an import error.

The temporary solution is to use the previous version:
sudo pip install -v gphoto2==1.5.0

Segfault on wait_for_event() when using python logging on Python 3.5

This works fine when you don't call gp.use_python_logging():

Python 3.5.2 (default, Nov 17 2016, 17:05:23) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import gphoto2 as gp

In [2]: gp.use_python_logging()
Out[2]: 1

In [3]: context = gp.gp_context_new()

In [4]: camera = gp.check_result(gp.gp_camera_new())

In [5]: camera.init(context)
(foreach_func [gphoto2-port-info-list.c:237]) Error during assembling of port list: 'Unspecified error' (-1).
(ptp_list_folder_eos [library.c:7017]) storage 0xffffffff, but handle 0x00000000?
(ptp_usb_getresp [usb.c:428]) PTP_OC 0x9109 receiving resp failed: PTP General Error (0x2002)
(ptp_list_folder_eos [library.c:7033]) 'ptp_canon_eos_getobjectinfoex ( params, storageids.Storage[k], handle ? handle : 0xffffffff, 0x100000, &tmp, &nroftmp)' failed: PTP General Error (0x2002)

In [6]: camera.wait_for_event(1000, context)
Segmentation fault (core dumped)

I'm using gphoto2==1.7.1 and libgphoto2-dev:amd64 2.5.9-3 from the standard Ubuntu 16.04 repositories.

Lengthy delay in capturing image

I am trying to capture an image within a short time window from another action, (i.e. open shutter 50ms after event x) but I am finding that there is a consistent delay between when the call is made and when the shutter is opened. Is there a way to "immediately" trigger the shutter release?

I setup like this:

        self.context = gp.gp_context_new()
        self.camera = gp.check_result(gp.gp_camera_new())
        gp.check_result(gp.gp_camera_init(self.camera, self.context))

And this is the call that takes roughly 1.5 seconds to open the shutter:

        self.file_path = gp.check_result(
            gp.gp_camera_capture(self.camera, gp.GP_CAPTURE_IMAGE, self.context)
        )

Is there any way around this delay?

(Question) I/O Problem with Canon EOS 5DS

Hi,

I'm running a python script (on Ubuntu 14.04) that uses gphoto2 to fire 2 Canon EOS 5DS simultaneously and then save the picture on the computer. It seems to work well for a minute or so, but then I get a "error: [-7] I/O problem" from both cameras when issues the capture command (gp.check_result(gp.gp_camera_capture(self.camera, gp.GP_CAPTURE_IMAGE, self.context))). Has anyone else also encountered I/O problems with EOS 5DS? Fyi, I'm using 2 USB 3.0 micro cable plugged into a usb 3.0 powered hub.

Thanks!

PS - I posted this issue on the gphoto2 mailing list also. Just wanted to get an opinion on this channel as well.

Get list of available config OOP

Hi Jim,

I want to list all available config options like camera-gui-config-oop.py file by using oop stracture. I inspected codebase but I'm not expert on C or SWIG. I tried camera.get_config(context) and it returns a SWIG object. How can i convert it to list or dict of possible values?

pip install not working on MAC OS X (Sierra)

I get the following

(apicbase)MacBook-Pro-5:libgphoto2-2.5.10 pieter$ pip install -v gphoto2
Downloading/unpacking gphoto2
Using version 1.4.1 (newest of versions: 1.4.1, 1.4.1, 1.4.0, 1.4.0, 1.3.4, 1.3.4, 1.3.3, 1.3.3, 1.3.2, 1.3.2, 1.3.1, 1.3.1, 1.2.2, 1.2.2, 1.2.1, 1.2.1, 1.2.0, 1.2.0, 1.1.0, 1.1.0, 1.0.0, 1.0.0, 0.11.2, 0.11.2, 0.11.1, 0.11.1, 0.11.0, 0.11.0, 0.10.2, 0.10.2, 0.10.1, 0.10.1, 0.10.0, 0.10.0, 0.9.1, 0.9.1, 0.9.0, 0.9.0, 0.8.0, 0.8.0, 0.7.1, 0.7.1, 0.7.0, 0.7.0, 0.6.0, 0.6.0, 0.5.2, 0.5.2, 0.5.1, 0.5.1, 0.5.0, 0.5.0, 0.4.0, 0.4.0, 0.3.3, 0.3.3, 0.3.2, 0.3.2)
Downloading gphoto2-1.4.1.zip (3.7MB):
Downloading from URL https://pypi.python.org/packages/3e/ae/981c4720259162a78fc6b309c3a591043b78a8dd35f3dd416025f62f69f4/gphoto2-1.4.1.zip#md5=afb3f20c657abcf8eb3193839ba65691 (from https://pypi.python.org/simple/gphoto2/)
...Downloading gphoto2-1.4.1.zip (3.7MB): 3.7MB downloaded
Running setup.py (path:/Users/pieter/.virtualenvs/apicbase/build/gphoto2/setup.py) egg_info for package gphoto2
running egg_info
creating pip-egg-info/gphoto2.egg-info
writing dependency_links to pip-egg-info/gphoto2.egg-info/dependency_links.txt
writing pip-egg-info/gphoto2.egg-info/PKG-INFO
writing top-level names to pip-egg-info/gphoto2.egg-info/top_level.txt
writing manifest file 'pip-egg-info/gphoto2.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found

reading manifest file 'pip-egg-info/gphoto2.egg-info/SOURCES.txt'
writing manifest file 'pip-egg-info/gphoto2.egg-info/SOURCES.txt'

Installing collected packages: gphoto2
Running setup.py install for gphoto2
running install
running build
running build_py
creating build
creating build/lib.macosx-10.12-intel-2.7
creating build/lib.macosx-10.12-intel-2.7/gphoto2
copying src/swig-bi-gp2.5-py2/init.py -> build/lib.macosx-10.12-intel-2.7/gphoto2
copying src/swig-bi-gp2.5-py2/abilities_list.py -> build/lib.macosx-10.12-intel-2.7/gphoto2
copying src/swig-bi-gp2.5-py2/camera.py -> build/lib.macosx-10.12-intel-2.7/gphoto2
copying src/swig-bi-gp2.5-py2/context.py -> build/lib.macosx-10.12-intel-2.7/gphoto2
copying src/swig-bi-gp2.5-py2/file.py -> build/lib.macosx-10.12-intel-2.7/gphoto2
copying src/swig-bi-gp2.5-py2/filesys.py -> build/lib.macosx-10.12-intel-2.7/gphoto2
copying src/swig-bi-gp2.5-py2/list.py -> build/lib.macosx-10.12-intel-2.7/gphoto2
copying src/swig-bi-gp2.5-py2/port.py -> build/lib.macosx-10.12-intel-2.7/gphoto2
copying src/swig-bi-gp2.5-py2/port_info_list.py -> build/lib.macosx-10.12-intel-2.7/gphoto2
copying src/swig-bi-gp2.5-py2/port_log.py -> build/lib.macosx-10.12-intel-2.7/gphoto2
copying src/swig-bi-gp2.5-py2/result.py -> build/lib.macosx-10.12-intel-2.7/gphoto2
copying src/swig-bi-gp2.5-py2/version.py -> build/lib.macosx-10.12-intel-2.7/gphoto2
copying src/swig-bi-gp2.5-py2/widget.py -> build/lib.macosx-10.12-intel-2.7/gphoto2
running build_ext
building '_abilities_list' extension
creating build/temp.macosx-10.12-intel-2.7
creating build/temp.macosx-10.12-intel-2.7/src
creating build/temp.macosx-10.12-intel-2.7/src/swig-bi-gp2.5-py2
cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/opt/local/include -I/opt/local/include -I/opt/local/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/swig-bi-gp2.5-py2/abilities_list_wrap.c -o build/temp.macosx-10.12-intel-2.7/src/swig-bi-gp2.5-py2/abilities_list_wrap.o -O3 -Wno-unused-variable -Wno-strict-prototypes -Werror -DGPHOTO2_25
cc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.12-intel-2.7/src/swig-bi-gp2.5-py2/abilities_list_wrap.o -L/opt/local/lib -lgphoto2 -lm -lgphoto2_port -lm -o build/lib.macosx-10.12-intel-2.7/gphoto2/_abilities_list.so
ld: warning: ld: warning: ignoring file /opt/local/lib/libgphoto2.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libgphoto2.dylibignoring file /opt/local/lib/libgphoto2_port.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libgphoto2_port.dylib

building '_camera' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/opt/local/include -I/opt/local/include -I/opt/local/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/swig-bi-gp2.5-py2/camera_wrap.c -o build/temp.macosx-10.12-intel-2.7/src/swig-bi-gp2.5-py2/camera_wrap.o -O3 -Wno-unused-variable -Wno-strict-prototypes -Werror -DGPHOTO2_25
cc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.12-intel-2.7/src/swig-bi-gp2.5-py2/camera_wrap.o -L/opt/local/lib -lgphoto2 -lm -lgphoto2_port -lm -o build/lib.macosx-10.12-intel-2.7/gphoto2/_camera.so
ld: warning: ld: warning: ignoring file /opt/local/lib/libgphoto2.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libgphoto2.dylibignoring file /opt/local/lib/libgphoto2_port.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libgphoto2_port.dylib

building '_context' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/opt/local/include -I/opt/local/include -I/opt/local/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/swig-bi-gp2.5-py2/context_wrap.c -o build/temp.macosx-10.12-intel-2.7/src/swig-bi-gp2.5-py2/context_wrap.o -O3 -Wno-unused-variable -Wno-strict-prototypes -Werror -DGPHOTO2_25
cc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.12-intel-2.7/src/swig-bi-gp2.5-py2/context_wrap.o -L/opt/local/lib -lgphoto2 -lm -lgphoto2_port -lm -o build/lib.macosx-10.12-intel-2.7/gphoto2/_context.so
ld: warning: ld: warning: ignoring file /opt/local/lib/libgphoto2.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libgphoto2.dylibignoring file /opt/local/lib/libgphoto2_port.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libgphoto2_port.dylib

building '_file' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/opt/local/include -I/opt/local/include -I/opt/local/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/swig-bi-gp2.5-py2/file_wrap.c -o build/temp.macosx-10.12-intel-2.7/src/swig-bi-gp2.5-py2/file_wrap.o -O3 -Wno-unused-variable -Wno-strict-prototypes -Werror -DGPHOTO2_25
src/swig-bi-gp2.5-py2/file_wrap.c:4310:68: error: implicit conversion loses integer precision: 'time_t' (aka 'long') to 'int' [-Werror,-Wshorten-64-to-32]
    resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg2)));
                                                    ~~~~~~~~~~~~~  ^~~~~
src/swig-bi-gp2.5-py2/file_wrap.c:4978:68: error: implicit conversion loses integer precision: 'time_t' (aka 'long') to 'int' [-Werror,-Wshorten-64-to-32]
    resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg2)));
                                                    ~~~~~~~~~~~~~  ^~~~~
2 errors generated.
error: command 'cc' failed with exit status 1
Complete output from command /Users/pieter/.virtualenvs/apicbase/bin/python -c "import setuptools, tokenize;__file__='/Users/pieter/.virtualenvs/apicbase/build/gphoto2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/44/m1ddz6bn01167z5g9j2f6yr80000gn/T/pip-hwTf0l-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/pieter/.virtualenvs/apicbase/include/site/python2.7:
running install

running build

running build_py

creating build

creating build/lib.macosx-10.12-intel-2.7

creating build/lib.macosx-10.12-intel-2.7/gphoto2

copying src/swig-bi-gp2.5-py2/init.py -> build/lib.macosx-10.12-intel-2.7/gphoto2

copying src/swig-bi-gp2.5-py2/abilities_list.py -> build/lib.macosx-10.12-intel-2.7/gphoto2

copying src/swig-bi-gp2.5-py2/camera.py -> build/lib.macosx-10.12-intel-2.7/gphoto2

copying src/swig-bi-gp2.5-py2/context.py -> build/lib.macosx-10.12-intel-2.7/gphoto2

copying src/swig-bi-gp2.5-py2/file.py -> build/lib.macosx-10.12-intel-2.7/gphoto2

copying src/swig-bi-gp2.5-py2/filesys.py -> build/lib.macosx-10.12-intel-2.7/gphoto2

copying src/swig-bi-gp2.5-py2/list.py -> build/lib.macosx-10.12-intel-2.7/gphoto2

copying src/swig-bi-gp2.5-py2/port.py -> build/lib.macosx-10.12-intel-2.7/gphoto2

copying src/swig-bi-gp2.5-py2/port_info_list.py -> build/lib.macosx-10.12-intel-2.7/gphoto2

copying src/swig-bi-gp2.5-py2/port_log.py -> build/lib.macosx-10.12-intel-2.7/gphoto2

copying src/swig-bi-gp2.5-py2/result.py -> build/lib.macosx-10.12-intel-2.7/gphoto2

copying src/swig-bi-gp2.5-py2/version.py -> build/lib.macosx-10.12-intel-2.7/gphoto2

copying src/swig-bi-gp2.5-py2/widget.py -> build/lib.macosx-10.12-intel-2.7/gphoto2

running build_ext

building '_abilities_list' extension

creating build/temp.macosx-10.12-intel-2.7

creating build/temp.macosx-10.12-intel-2.7/src

creating build/temp.macosx-10.12-intel-2.7/src/swig-bi-gp2.5-py2

cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/opt/local/include -I/opt/local/include -I/opt/local/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/swig-bi-gp2.5-py2/abilities_list_wrap.c -o build/temp.macosx-10.12-intel-2.7/src/swig-bi-gp2.5-py2/abilities_list_wrap.o -O3 -Wno-unused-variable -Wno-strict-prototypes -Werror -DGPHOTO2_25

cc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.12-intel-2.7/src/swig-bi-gp2.5-py2/abilities_list_wrap.o -L/opt/local/lib -lgphoto2 -lm -lgphoto2_port -lm -o build/lib.macosx-10.12-intel-2.7/gphoto2/_abilities_list.so

ld: warning: ld: warning: ignoring file /opt/local/lib/libgphoto2.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libgphoto2.dylibignoring file /opt/local/lib/libgphoto2_port.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libgphoto2_port.dylib

building '_camera' extension

cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/opt/local/include -I/opt/local/include -I/opt/local/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/swig-bi-gp2.5-py2/camera_wrap.c -o build/temp.macosx-10.12-intel-2.7/src/swig-bi-gp2.5-py2/camera_wrap.o -O3 -Wno-unused-variable -Wno-strict-prototypes -Werror -DGPHOTO2_25

cc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.12-intel-2.7/src/swig-bi-gp2.5-py2/camera_wrap.o -L/opt/local/lib -lgphoto2 -lm -lgphoto2_port -lm -o build/lib.macosx-10.12-intel-2.7/gphoto2/_camera.so

ld: warning: ld: warning: ignoring file /opt/local/lib/libgphoto2.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libgphoto2.dylibignoring file /opt/local/lib/libgphoto2_port.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libgphoto2_port.dylib

building '_context' extension

cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/opt/local/include -I/opt/local/include -I/opt/local/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/swig-bi-gp2.5-py2/context_wrap.c -o build/temp.macosx-10.12-intel-2.7/src/swig-bi-gp2.5-py2/context_wrap.o -O3 -Wno-unused-variable -Wno-strict-prototypes -Werror -DGPHOTO2_25

cc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.12-intel-2.7/src/swig-bi-gp2.5-py2/context_wrap.o -L/opt/local/lib -lgphoto2 -lm -lgphoto2_port -lm -o build/lib.macosx-10.12-intel-2.7/gphoto2/_context.so

ld: warning: ld: warning: ignoring file /opt/local/lib/libgphoto2.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libgphoto2.dylibignoring file /opt/local/lib/libgphoto2_port.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libgphoto2_port.dylib

building '_file' extension

cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/opt/local/include -I/opt/local/include -I/opt/local/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/swig-bi-gp2.5-py2/file_wrap.c -o build/temp.macosx-10.12-intel-2.7/src/swig-bi-gp2.5-py2/file_wrap.o -O3 -Wno-unused-variable -Wno-strict-prototypes -Werror -DGPHOTO2_25

src/swig-bi-gp2.5-py2/file_wrap.c:4310:68: error: implicit conversion loses integer precision: 'time_t' (aka 'long') to 'int' [-Werror,-Wshorten-64-to-32]

resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg2)));

                                                ~~~~~~~~~~~~~  ^~~~~

src/swig-bi-gp2.5-py2/file_wrap.c:4978:68: error: implicit conversion loses integer precision: 'time_t' (aka 'long') to 'int' [-Werror,-Wshorten-64-to-32]

resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg2)));

                                                ~~~~~~~~~~~~~  ^~~~~

2 errors generated.

error: command 'cc' failed with exit status 1


Cleaning up...
Removing temporary dir /Users/pieter/.virtualenvs/apicbase/build...
Command /Users/pieter/.virtualenvs/apicbase/bin/python -c "import setuptools, tokenize;file='/Users/pieter/.virtualenvs/apicbase/build/gphoto2/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /var/folders/44/m1ddz6bn01167z5g9j2f6yr80000gn/T/pip-hwTf0l-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/pieter/.virtualenvs/apicbase/include/site/python2.7 failed with error code 1 in /Users/pieter/.virtualenvs/apicbase/build/gphoto2
Exception information:
Traceback (most recent call last):
File "/Users/pieter/.virtualenvs/apicbase/lib/python2.7/site-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/Users/pieter/.virtualenvs/apicbase/lib/python2.7/site-packages/pip/commands/install.py", line 283, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/Users/pieter/.virtualenvs/apicbase/lib/python2.7/site-packages/pip/req.py", line 1435, in install
requirement.install(install_options, global_options, _args, *_kwargs)
File "/Users/pieter/.virtualenvs/apicbase/lib/python2.7/site-packages/pip/req.py", line 706, in install
cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
File "/Users/pieter/.virtualenvs/apicbase/lib/python2.7/site-packages/pip/util.py", line 697, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command /Users/pieter/.virtualenvs/apicbase/bin/python -c "import setuptools, tokenize;file='/Users/pieter/.virtualenvs/apicbase/build/gphoto2/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /var/folders/44/m1ddz6bn01167z5g9j2f6yr80000gn/T/pip-hwTf0l-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/pieter/.virtualenvs/apicbase/include/site/python2.7 failed with error code 1 in /Users/pieter/.virtualenvs/apicbase/build/gphoto2

Storing debug log for failure in /Users/pieter/.pip/pip.log

In short it has to do with handling integers (probably a difference on mac).

I have libgphoto installed. Any help is welcome!

Kind regards,

Pieter

NameError: name 'GP_ERROR_CANCEL' is not defined

Using this example below:

import gphoto2 as gp
context = gp.Context()
camera = gp.Camera()
camera.init(context)
text = camera.get_summary(context)
print('Summary')
print('=======')
print(str(text))
camera.exit(context)

I get the following errors:

File "libgphoto_example.py", line 1, in
import gphoto2 as gp
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 86, in
import gphoto2.camera
File "/usr/local/lib/python2.7/dist-packages/gphoto2/camera.py", line 87, in
import gphoto2.context
File "/usr/local/lib/python2.7/dist-packages/gphoto2/context.py", line 88, in
import gphoto2.file
File "/usr/local/lib/python2.7/dist-packages/gphoto2/file.py", line 89, in
import gphoto2.filesys
File "/usr/local/lib/python2.7/dist-packages/gphoto2/filesys.py", line 90, in
import gphoto2.list
File "/usr/local/lib/python2.7/dist-packages/gphoto2/list.py", line 91, in
import gphoto2.port_info_list
File "/usr/local/lib/python2.7/dist-packages/gphoto2/port_info_list.py", line 92, in
import gphoto2.port_log
File "/usr/local/lib/python2.7/dist-packages/gphoto2/port_log.py", line 93, in
import gphoto2.result
File "/usr/local/lib/python2.7/dist-packages/gphoto2/result.py", line 100, in
GP_ERROR_CANCEL : logging.INFO,
NameError: name 'GP_ERROR_CANCEL' is not defined

Error 105 Unknown model for Nikon D40

Hi!

I have install gphoto2 and now I was trying to deal with the python interface
I am trying to detect the camera but by using a simple code like this:

gp.check_result(gp.use_python_logging())
context = gp.gp_context_new()
camera = gp.check_result(gp.gp_camera_new())
gp.check_result(gp.gp_camera_init(camera, context))

I got an error message "Unknwon model[105]" when my camera is a Nikon D40, which is in the list

If I use the terminal interface with:

gphoto2 --auto-detect

the camera is correctly detected

Where is my mistake?

Thank you

Stefano

ImportError: No module named _list

Hi, great stuff here and I would like to try it on a new RaspberryPI 3 distro pi64 https://github.com/bamarni/pi64.

Installed libgphoto 2.5.15 based on http://blog.marcelkrauskopfphotography.de/category/raspberry-pi/
Installed python-gphoto by sudo pip install -v gphoto2 without problems.

...
  Removing source in /tmp/pip-build-OjKwUf/gphoto2
Successfully built gphoto2
Installing collected packages: gphoto2

Successfully installed gphoto2-1.7.1
Cleaning up...

lsusb gives me

Bus 001 Device 006: ID 04b0:0422 Nikon Corp. D700 (ptp)
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

But running the example return exceptions:

root@pi64:/home/pi# python /usr/local/share/python-gphoto2/examples/camera-summary.py
Traceback (most recent call last):
  File "/usr/local/share/python-gphoto2/examples/camera-summary.py", line 25, in <module>
    import gphoto2 as gp
  File "/usr/local/lib/python2.7/dist-packages/gphoto2/__init__.py", line 3, in <module>
    from gphoto2.abilities_list import *
  File "/usr/local/lib/python2.7/dist-packages/gphoto2/abilities_list.py", line 6, in <module>
    import gphoto2.context
  File "/usr/local/lib/python2.7/dist-packages/gphoto2/context.py", line 6, in <module>
    import gphoto2.list
  File "/usr/local/lib/python2.7/dist-packages/gphoto2/list.py", line 17, in <module>
    _list = swig_import_helper()
  File "/usr/local/lib/python2.7/dist-packages/gphoto2/list.py", line 16, in swig_import_helper
    return importlib.import_module('_list')
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named _list

Using Python 2.7.13 and libgphoto2-2.5.15.

Any ideas would be appreciated. Best regards,
Nic

Camera blocks after using the download script

Hi,

Thanks for the cool product.
After running images download script, the camera (Canon 750D) locks and show "busy" when trying to make a new photo.

The script has "gp.gp_camera_exit(camera)" at the end.

Trying to use "gp.gp_camera_free(camera)" at the end of the script, causing error, is it implemented? Can it help?

The second weird thing is, sometimes it works and the camera is not locked, sometime it does not.

Thanks.

LivePreview

Hi Jim,

i have a Question. Is there a LivePreview like in piggyphoto?

Best regards
ScooB

gp_camera_wait_for_event ignores timeout, blocks for a long time

With the Canon EOS 600D, I'm polling gp_camera_wait_for_event in an endless loop with a timeout of 1 (ms). After physically triggering a shot on the camera, the function produces a GP_EVENT_FILE_ADDED event, but not before blocking for about 1.2 seconds. The duration is reduced when taking smaller pictures, so this might be the time it takes to download the image.

My goal is to download images in small chunks while keeping the loop interactive. Seems like this should be doable.

ImportError: libgphoto2_port.so.10

Hi. I just upgraded libgphoto2 and gphoto2 to following versions:

gphotot2: 2.5.10
libgphotot2: 2.5.10
libgphoto2_port 0.12.0

Also, I installed python-gphoto2 via pip, and it installed the 1.4.1 version.

However, when I import gphoto2 in python, I get the following error:

ImportError: libgphoto2_port.so.10: cannot open shared object file: No such file or directory

In /usr/local/lib, I see libgphoto2_port.so.12 file. Is python-gphoto2 not compatible with the latest version of libgphoto2 and libgphoto2_port?

Thanks!

Most recent branch

I'm not sure exactly when this happened, but my examples no longer work with the latest build - here is the issue that I ran into:

This is what I have in my branch:
def gp_camera_capture(*args):
"""
gp_camera_capture(camera, type, path, context) -> int

Parameters:
    camera: Camera *
    type: enum CameraCaptureType
    path: CameraFilePath *
    context: GPContext *

"""

return _gphoto2_camera.gp_camera_capture(*args)

The "path: CameraFilePath *" no longer exists when I run in your latest version, so I can't make use of the capture / trigger_capture functions anymore.

Thanks,
Matt

Compile error in (Py_ssize_t)offsetof(SwigPyObject, dict)

If you have SWIG version 2.0.11 ('swig -version' will show you) you may get errors like this:

running build
running build_ext
building '_gphoto2_abilities_list' extension
swigging src/gphoto2/lib/gphoto2_abilities_list.i to src/gphoto2/lib/gphoto2_abilities_list_wrap.c
swig -python -I/usr/include -builtin -O -Wall -DGPHOTO2_25 -o src/gphoto2/lib/gphoto2_abilities_list_wrap.c src/gphoto2/lib/gphoto2_abilities_list.i
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/gphoto2/lib/gphoto2_abilities_list_wrap.c -o build/temp.linux-x86_64-2.7/src/gphoto2/lib/gphoto2_abilities_list_wrap.o -O3 -Wno-unused-variable -DGPHOTO2_25
src/gphoto2/lib/gphoto2_abilities_list_wrap.c:5580:5: warning: implicit declaration of function `offsetof' [-Wimplicit-function-declaration]
     (Py_ssize_t)offsetof(SwigPyObject, dict), /* tp_dictoffset */
     ^
src/gphoto2/lib/gphoto2_abilities_list_wrap.c:5580:26: error: expected expression before `SwigPyObject'
     (Py_ssize_t)offsetof(SwigPyObject, dict), /* tp_dictoffset */

If this happens, edit setup.py and remove '-builtin' from the swig_opts declaration.

TypeError: gp_camera_capture expected 3 arguments, got 4

Hi - the API specifies 4 arguments . I have check the swig *.i files but with my limited knowledge cannot see any issues.

I have changed swig to version 3.0.2 which works ok with the latest source. . I might change back to a pre 2.0.11 of swig and see if that helps. Any other ideas?

bash-4.2$ python trigger-image-to-disk.py 
ERROR: gphoto2: (ptp2/eos_directory) storage 0xffffffff, but handle 0x00000000?
ERROR: gphoto2: (camera_canon_eos_update_capture_target) did not get capture destination propdesc?
Traceback (most recent call last):
  File "trigger-image-to-disk.py", line 46, in <module>
    sys.exit(main())
  File "trigger-image-to-disk.py", line 38, in main
    gp.check_result(gp.gp_camera_capture(camera, gp.GP_CAPTURE_IMAGE , "dddd.cr2", context))
  File "/usr/lib64/python2.7/site-packages/gphoto2/lib/gphoto2_camera.py", line 782, in gp_camera_capture
    return _gphoto2_camera.gp_camera_capture(*args)
TypeError: gp_camera_capture expected 3 arguments, got 4
bash-4.2$ swig -v
Must specify an input file. Use -help for available options.
bash-4.2$ swig -version

SWIG Version 3.0.2

Compiled with g++ [x86_64-unknown-linux-gnu]

Configured options: +pcre

Please see http://www.swig.org for reporting bugs and further information
bash-4.2$

Is an empty result for GP_STORAGEINFO_DESCRIPTION indicative of a bug?

Hi Jim,

A user with a Nikon D800 is finding that getting storage info description is failing. There is no exception -- it's just there appears to be no value, or else the field is not set. I've not come across this problem with any other camera, although it's possible other users have not reported the problem of course.

Does this look more like "works as expected" or "looks like a bug"?

Here is an excerpt of code to provide a context for the problem:

    def get_storage_descriptions(self, refresh: bool=False) -> List[str]:
        """
        Storage description is used in MTP path names by gvfs and KDE.

        :param refresh: if True, get updated instead of cached values
        :return: the storage description
        """
        self._get_storage_info(refresh)
        descriptions = []
        for media_index in range(len(self.storage_info)):
            info = self.storage_info[media_index]
            if info.fields & gp.GP_STORAGEINFO_DESCRIPTION:
                descriptions.append(info.description)
        return descriptions

    def _get_storage_info(self, refresh: bool):
        """
        Load the gphoto2 storage information
        :param refresh: if True, refresh the storage information, i.e.
         load it
        """
        if not self.storage_info or refresh:
            try:
                self.storage_info = self.camera.get_storageinfo(self.context)
            except gp.GPhoto2Error as e:
                logging.error(
                    "Unable to determine storage info for camera %s: error %s.",
                    self.display_name, e.code
                )
                self.storage_info = []

I've got the user to generate a debug log dump if that would help (i.e. with gphoto2 logging turned on). Let me know if you'd like me to attach it to this report.

If you want to try some code yourself, install Rapid Photo Downloader 0.9.0b4 and run
rapid-photo-downloader --camera-info

Thanks.

Best,
Damon

Repeated checks for camera causes memory leak

I'm attempting to write a program which acts a lot like --capture-tethered but doesn't quit when the camera is removed. I'm doing something analogous to the following, but it's eventually consuming all of my memory:

leaktest.py

import sys

import gphoto2 as gp


def write(msg):
    sys.stdout.write(msg)
    sys.stdout.flush()


def get_camera(context):
    camera = None
    write("Waiting for a camera...")
    while True:
        try:
            camera = gp.check_result(gp.gp_camera_new())
            camera.init(context)
            print("DONE")
            return camera
        except gp.GPhoto2Error:
            write(".")
        finally:
            # Just in case the reassignment somehow doesn't dereference `camera`.
            if camera is not None:
                del camera


def wait_for_image(camera, context, timeout=1000):
    status = None
    write("Waiting for an image...")
    while status != gp.GP_EVENT_FILE_ADDED:
        status, output = camera.wait_for_event(timeout, context)
        write(".")
    print("DONE")
    return output


context = gp.gp_context_new()
while True:
    camera = get_camera(context)
    try:
        while True:
            img_info = wait_for_image(camera, context)
            # Do things with img_info etc.
            print("You took a photo!")
    except gp.GPhoto2Error:
        print("\nCamera disconnected!")
    finally:
        try:
            camera.exit(context)
            print("Cleanly exited camera.")
        except gp.GPhoto2Error:
            # Well, we tried.
            print("Unable to exit camera cleanly.")
        del camera

PS. The real version has some more sensible sleep() calls etc, but this should demonstrate the point.

If you run python leaktest.py and in another terminal, watch -d "ps aux | grep leaktest | grep -v grep" without a camera attached, then you should see the memory usage creep up continuously.

Am I doing this wrong? If I keep the existing camera object around and try to init() it again, it says something along the lines of Bad Parameters.

Cheers

Time for capture and download increases over time

I am using a Nikon D300 connected to a Raspberry Pi to capture JPGs and I am running into the following problem: The process to capture and download the images takes more and more time...

As you can see below, the problem begins with the second picture, so I doubt that it is caused by a shortage of RAM.

To reproduce:

import gphoto2 as gp
from time import perf_counter

camera  = gp.check_result(gp.gp_camera_new())
context = gp.gp_context_new()
gp.check_result(gp.gp_camera_init(camera, context))

print("Camera init completed")


i=0
while True:
  i+=1
  start = perf_counter()

  camera_file_path = gp.check_result(gp.gp_camera_capture(camera, gp.GP_CAPTURE_IMAGE, context))
  camera_file = gp.check_result(gp.gp_camera_file_get(camera, camera_file_path.folder, camera_file_path.name, gp.GP_FILE_TYPE_NORMAL, context))

  gp.gp_file_save(camera_file, "photo{0:03d}".format(i))
  gp.gp_camera_file_delete(camera, camera_file_path.folder, camera_file_path.name, context)

  del camera_file, camera_file_path

  timing = perf_counter() - start
  print("photo{0:03d} timing: {1:.3f}".format(i, timing))

The output:

Camera init completed
photo001 timing: 1.743
photo002 timing: 1.909
photo003 timing: 2.172
photo004 timing: 2.334
photo005 timing: 2.393
photo006 timing: 2.515
photo007 timing: 2.595
photo008 timing: 2.957
photo009 timing: 3.268
photo010 timing: 3.565
photo011 timing: 3.728
photo012 timing: 4.072
photo013 timing: 4.562
photo014 timing: 4.815
photo015 timing: 5.044
photo016 timing: 5.488
photo017 timing: 5.957
photo018 timing: 6.463
photo019 timing: 6.970
photo020 timing: 7.454
photo021 timing: 7.564
photo022 timing: 7.889
photo023 timing: 8.013

Best regards,
scus1

PIP install on OSX, 'error: too few arguments'

I wanted to install python-gphoto2 via pip on my laptop running OSX 10.10 Yosemite. Unfortunately, the installation procedure fails:

    src/swig-gp2.5/gphoto2_port_log_wrap.c:4120:57: error: too few arguments to function call, expected at least 4, have 3

      gp_log_data((char const *)arg1,(char const *)arg2,arg3);
      ~~~~~~~~~~~                                           ^

    /usr/local/Cellar/libgphoto2/2.5.7/include/gphoto2/gphoto2-port-log.h:88:1: note: 'gp_log_data' declared here

    void gp_log_data (const char *domain, const char *data, unsigned int size,

    ^

    1 error generated.

    error: command 'clang' failed with exit status 1

I have a recent installation of gphoto2:

    This version of gphoto2 is using the following software versions and options:
    gphoto2         2.5.6          clang, popt(m), no exif, no cdk, no aa, jpeg, readline
    libgphoto2      2.5.7          all camlibs, clang, ltdl, no EXIF
    libgphoto2_port 0.12.0         clang, ltdl, USB, serial without locking

Interestingly, when I clone the git repo and install this, the installation runs through and it seems fine. At least I get the examples to run. They are producing some errors, but I can see output from the camera.

    $ python camera-summary.py
    ERROR: gphoto2: (foreach_func [gphoto2-port-info-list.c:237]) Error during assembling of port list: 'Unspecified error' (-1).
    ERROR: gphoto2: (gp_port_usb_close [libusb.c:322]) Invalid parameters: 'port && port->pl->dh' is NULL/FALSE.
    ERROR: gphoto2: (ptp_list_folder_eos [library.c:6674]) storage 0xffffffff, but handle 0x00000000?
    Summary
    =======
    Manufacturer: Canon Inc.
    Model: Canon EOS 600D
      Version: 3-1.0.2
    […]

When I do the same with gphoto2 directly, these errors don't appear:

    $ gphoto2 --summary
    Camera summary:                                                                
    Manufacturer: Canon Inc.
    Model: Canon EOS 600D
      Version: 3-1.0.2

So right now I think I'm fine, but it seems strange why it doesn't work via pip.

Multiple warnings when capturing an image

I'm using the latest version go python-gphoto2 and experiencing the following warnings when capturing a picture (Canon 600D) on a Raspberry Pi 2:

WARNING: gphoto2: (foreach_func [gphoto2-port-info-list.c:237]) Error during assembling of port list: 'Unspecified error' (-1).
WARNING: gphoto2: (ptp_list_folder_eos [library.c:7017]) storage 0xffffffff, but handle 0x00000000?
Capturing image
WARNING: gphoto2: (camera_canon_eos_capture [library.c:3088]) no focus info?
Camera file path: /store_00020001/DCIM/100CANON/IMG_3223.JPG
Copying image to /tmp/IMG_3223.JPG
WARNING: gphoto2: (ptp_usb_getresp [usb.c:428]) PTP_OC 0x911c receiving resp failed: PTP Device Busy (0x2019)
WARNING: gphoto2: (camera_unprepare_canon_eos_capture [config.c:450]) 'ptp_canon_eos_resetuilock (params)' failed: PTP Device Busy (0x2019)

Using the command line, there is no warning.

Installed gphoto2 info:

gphoto2         2.5.9          gcc, popt(m), exif, no cdk, no aa, jpeg, no readline
libgphoto2      2.5.9          all camlibs, gcc, ltdl, EXIF
libgphoto2_port 0.12.0         gcc, ltdl, USB, serial without locking

Install errors Mac osx

I am having issues trying to pip install, I have installed SWIG, but still can't get past this issue, thanks for your help

-strict-prototypes -Werror -DGPHOTO2_25
src/swig-bi-gp2.5-py2/file_wrap.c:4732:80: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'unsigned int' [-Werror,-Wshorten-64-to-32]
resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_unsigned_SS_int((_arg4)));
~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~
src/swig-bi-gp2.5-py2/file_wrap.c:5407:80: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'unsigned int' [-Werror,-Wshorten-64-to-32]
resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_unsigned_SS_int((_arg4)));
~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~
2 errors generated.
error: command 'cc' failed with exit status 1


Failed building wheel for gphoto2
Running setup.py clean for gphoto2
Failed to build gphoto2

Canon focus control?

I'd like to be able to remotely adjust the focus of my Canon T5i. The best that I can currently do is to use the setting "Drive Canon DSLR Manual Focus" (with "Continuous AF" set to "Off") and set it to something like "Far 3" or "Near 3", which I can see changes the focus. Then I can make it oscillate back and forth using "Far 3", "Near 3", "Far 3", etc.. However I can't figure out how to make it "walk" in one direction, i.e. "Far 3" followed by "Far 3" doesn't do anything. This only seems to work if I exit my program and restart it, but hopefully there is a better way.

camera.wait_for_event works?

Hi,

I'm testing the wait_for_event method now, the idea is to download the files.

        context = gp.Context()
        camera = gp.Camera()
        camera.init(context)

        while True:
                type, data = camera.wait_for_event(1000, context)
                print "gp_camera_wait_for_event:", type, data
                if type == gp.GP_EVENT_FILE_ADDED:
                    pass
                if type == gp.GP_EVENT_TIMEOUT:
                    pass

                time.sleep(0.5) # Solved: should be removed

The "type" is always 0, and the output looks like this:
gp_camera_wait_for_event: 0 PTP Property d105 changed
gp_camera_wait_for_event: 0 PTP Property d108 changed
gp_camera_wait_for_event: 0 PTP Property d106 changed
gp_camera_wait_for_event: 0 PTP Property d107 changed

Should it be different?

I'm checking the "sample-tether.c" code from a library (it works btw:), there are 2 additional parameters:
CameraEventType evttype;
CameraFilePath *path;
retval = gp_camera_wait_for_event (camera, 1000, &evttype, &evtdata, context);

I tried to do the same like this (maybe wrong ctypes usage):
intc = ctypes.c_int(0)
char_data = ctypes.c_char_p(0)
type, data = camera.wait_for_event(1000, ctypes.pointer(intc), ctypes.pointer(char_data), context)

But getting the error "TypeError: Camera_wait_for_event expected at most 2 arguments, got 4".

In the "camera.i" I see:
MEMBER_FUNCTION_THREAD(_Camera, Camera,
wait_for_event,
(int timeout, CameraEventType *eventtype, void **eventdata, GPContext *context),
gp_camera_wait_for_event, ($self, timeout, eventtype, eventdata, context))

So, it should support 4 arguments? Or something was changed?

Thanks

Build failed

I'm absolutely unsure whether I'm missing a concept or this is really an issue. When running the build command I'm gettings this:

benoit@ubuntu:~/dev/python-gphoto2$ python setup.py build
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/gphoto2
copying gphoto2/init.py -> build/lib.linux-x86_64-2.7/gphoto2
running build_ext
building '_gphoto2_abilities_list' extension
swigging gphoto2/gphoto2_abilities_list.i to gphoto2/gphoto2_abilities_list_wrap.c
swig -python -I/usr/include -builtin -O -Wall -o gphoto2/gphoto2_abilities_list_wrap.c gphoto2/gphoto2_abilities_list.i
gphoto2/gphoto2_context.i:28: Error: Unable to find 'gphoto2/gphoto2-context.h'
gphoto2/gphoto2_port_info_list.i:73: Error: Unable to find 'gphoto2/gphoto2-port-info-list.h'
gphoto2/gphoto2_abilities_list.i:44: Error: Unable to find 'gphoto2/gphoto2-abilities-list.h'
error: command 'swig' failed with exit status 1

There are no .h files in the gphoto2 folder, so it makes sense it would be failing - why are there no .h files?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.