pupil-labs / pyuvc

python binding to libuvc
Other
119 stars 51 forks source link

Failed building wheel for uvc #78

Closed alitoufighi closed 3 years ago

alitoufighi commented 3 years ago

I wanted to install uvc as a dependency of pupil project. Using Python 3.8 and pip v20.2.4, when I run pip install git+https://github.com/pupil-labs/pyuvc@v0.14.1 I get:

Collecting git+https://github.com/pupil-labs/pyuvc@v0.14.1
  Cloning https://github.com/pupil-labs/pyuvc (to revision v0.14.1) to /tmp/pip-req-build-7mio5nmu
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Requirement already satisfied: numpy in ./venv/lib/python3.8/site-packages (from uvc==0.14) (1.19.4)
Building wheels for collected packages: uvc
  Building wheel for uvc (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/alitou/Projects/pupil/venv/bin/python3 /home/alitou/Projects/pupil/venv/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmp4a4ympnq
       cwd: /tmp/pip-req-build-7mio5nmu
  Complete output (51 lines):
  running bdist_wheel
  running build
  running build_ext
  building 'uvc' extension
  creating build
  creating build/temp.linux-x86_64-3.8
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/tmp/pip-build-env-gtjgahv8/overlay/lib/python3.8/site-packages/numpy/core/include -I/home/alitou/Projects/pupil/venv/include -I/usr/include/python3.8 -c uvc.c -o build/temp.linux-x86_64-3.8/uvc.o
  In file included from /tmp/pip-build-env-gtjgahv8/overlay/lib/python3.8/site-packages/numpy/core/include/numpy/ndarraytypes.h:1822,
                   from /tmp/pip-build-env-gtjgahv8/overlay/lib/python3.8/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                   from /tmp/pip-build-env-gtjgahv8/overlay/lib/python3.8/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                   from uvc.c:640:
  /tmp/pip-build-env-gtjgahv8/overlay/lib/python3.8/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
     17 | #warning "Using deprecated NumPy API, disable it with " \
        |  ^~~~~~~
  uvc.c: In function ‘__pyx_f_3uvc_7Capture__start’:
  uvc.c:15711:20: error: too many arguments to function ‘uvc_stream_start’
  15711 |   __pyx_v_status = uvc_stream_start(__pyx_v_self->strmh, NULL, NULL, __pyx_v_self->_bandwidth_factor, 0);
        |                    ^~~~~~~~~~~~~~~~
  In file included from uvc.c:637:
  /usr/include/libuvc/libuvc.h:567:13: note: declared here
    567 | uvc_error_t uvc_stream_start(uvc_stream_handle_t *strmh,
        |             ^~~~~~~~~~~~~~~~
  uvc.c: In function ‘__pyx_pf_3uvc_7Capture_8get_frame’:
  uvc.c:16813:42: warning: comparison of integer expressions of different signedness: ‘uint32_t’ {aka ‘unsigned int’} and ‘int’ [-Wsign-compare]
  16813 |   __pyx_t_7 = ((__pyx_v_uvc_frame->width == __pyx_v_j_width) != 0);
        |                                          ^~
  uvc.c:16819:43: warning: comparison of integer expressions of different signedness: ‘uint32_t’ {aka ‘unsigned int’} and ‘int’ [-Wsign-compare]
  16819 |   __pyx_t_7 = ((__pyx_v_uvc_frame->height == __pyx_v_j_height) != 0);
        |                                           ^~
  uvc.c: In function ‘__pyx_f_3uvc_7Capture__enumerate_controls’:
  uvc.c:16995:26: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  16995 |   __pyx_v_input_terminal = uvc_get_input_terminals(__pyx_v_self->devh);
        |                          ^
  uvc.c:17004:27: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  17004 |   __pyx_v_output_terminal = uvc_get_output_terminals(__pyx_v_self->devh);
        |                           ^
  uvc.c:17013:27: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  17013 |   __pyx_v_processing_unit = uvc_get_processing_units(__pyx_v_self->devh);
        |                           ^
  uvc.c:17022:26: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  17022 |   __pyx_v_extension_unit = uvc_get_extension_units(__pyx_v_self->devh);
        |                          ^
  uvc.c: In function ‘__pyx_f_3uvc_7Capture__enumerate_formats’:
  uvc.c:17597:23: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  17597 |   __pyx_v_format_desc = uvc_get_format_descs(__pyx_v_self->devh);
        |                       ^
  At top level:
  uvc.c:20000:13: warning: ‘__pyx_f_3uvc_on_status_update’ defined but not used [-Wunused-function]
  20000 | static void __pyx_f_3uvc_on_status_update(CYTHON_UNUSED enum uvc_status_class __pyx_v_status_class, CYTHON_UNUSED int __pyx_v_event, CYTHON_UNUSED int __pyx_v_selector, CYTHON_UNUSED enum uvc_status_attribute __pyx_v_status_attribute, CYTHON_UNUSED void *__pyx_v_data, CYTHON_UNUSED size_t __pyx_v_data_len, CYTHON_UNUSED void *__pyx_v_user_ptr) {
        |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for uvc
Failed to build uvc
ERROR: Could not build wheels for uvc which use PEP 517 and cannot be installed directly

The error is apparently in this line: error: too many arguments to function ‘uvc_stream_start’. Is it related to my Python version, or something with Cython or numpy caused the problem?

papr commented 3 years ago

@alitoufighi Hi, at first sight, it looks like you have installed an incompatible libuvc version. Could you let us know how you installed libuvc?

alitoufighi commented 3 years ago

Hi. Thank you for your quick response. I just noticed that I had installed libuvc-dev from ubuntu repositories. I uninstalled it and built it from your fork and it installed successfully.

I'll close the issue.

AvinashNargund commented 1 year ago

I am seeing the same error when trying to install pyuvc on a Jetson nano (Ubuntu 18.04, python 3.6.9). I have installed the pupil-lab fork of libuvc. Any idea why this could be happening?

papr commented 1 year ago

@AvinashNargund you might have both libuvc-dev and the fork installed, and while building pyuvc, it uses libuvc-dev.

I recommend 1) uninstalling libuvc-dev 2) Follow the latest "Install from source instructions" with a fresh clone

If you continue having issues, please share the full build log.

AvinashNargund commented 1 year ago

I have only the Pupil lab fork of the libuvc installed. I followed the instructions from the page you linked and the setup fails with the error /tmp/pip-c_bmt_qa-build/pyuvc-source/uvc_bindings.pyx:705:30: undeclared name not builtin: TimeoutError Here's the full log -

Processing ./pyuvc
Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from pupil-labs-uvc==0.0.0)
Requirement already satisfied: importlib-metadata in /usr/local/lib/python3.6/dist-packages (from pupil-labs-uvc==0.0.0)
Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.6/dist-packages (from importlib-metadata->pupil-labs-uvc==0.0.0)
Requirement already satisfied: typing-extensions>=3.6.4; python_version < "3.8" in /usr/local/lib/python3.6/dist-packages (from importlib-metadata->pupil-labs-uvc==0.0.0)
Installing collected packages: pupil-labs-uvc
  Running setup.py install for pupil-labs-uvc: started
    Running setup.py install for pupil-labs-uvc: finished with status 'error'
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-c_bmt_qa-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-0iq83u0w-record/install-record.txt --single-version-externally-managed --compile:
    /usr/local/lib/python3.6/dist-packages/setuptools/command/install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
      setuptools.SetuptoolsDeprecationWarning,

    --------------------------------------------------------------------------------
    -- Trying 'Ninja' generator
    --------------------------------
    ---------------------------
    ----------------------
    -----------------
    ------------
    -------
    --
    Not searching for unused variables given on the command line.
    CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
    -- Configuring incomplete, errors occurred!
    See also "/tmp/pip-c_bmt_qa-build/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
    --
    -------
    ------------
    -----------------
    ----------------------
    ---------------------------
    --------------------------------
    -- Trying 'Ninja' generator - failure
    --------------------------------------------------------------------------------

    --------------------------------------------------------------------------------
    -- Trying 'Unix Makefiles' generator
    --------------------------------
    ---------------------------
    ----------------------
    -----------------
    ------------
    -------
    --
    Not searching for unused variables given on the command line.
    -- The C compiler identification is GNU 7.5.0
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: /usr/bin/cc - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- The CXX compiler identification is GNU 7.5.0
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: /usr/bin/c++ - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /tmp/pip-c_bmt_qa-build/_cmake_test_compile/build
    --
    -------
    ------------
    -----------------
    ----------------------
    ---------------------------
    --------------------------------
    -- Trying 'Unix Makefiles' generator - success
    --------------------------------------------------------------------------------

    Configuring Project
      Working directory:
        /tmp/pip-c_bmt_qa-build/_skbuild/linux-aarch64-3.6/cmake-build
      Command:
        /usr/bin/cmake /tmp/pip-c_bmt_qa-build/pyuvc-source -G 'Unix Makefiles' -DCMAKE_INSTALL_PREFIX:PATH=/tmp/pip-c_bmt_qa-build/_skbuild/linux-aarch64-3.6/cmake-install/pyuvc-source/uvc -DPYTHON_VERSION_STRING:STRING=3.6.9 -DSKBUILD:INTERNAL=TRUE -DCMAKE_MODULE_PATH:PATH=/usr/local/lib/python3.6/dist-packages/skbuild/resources/cmake -DPYTHON_EXECUTABLE:PATH=/usr/bin/python3 -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.6m -DPYTHON_LIBRARY:PATH=/usr/lib/aarch64-linux-gnu/libpython3.6m.so -DPython_EXECUTABLE:PATH=/usr/bin/python3 -DPython_ROOT_DIR:PATH=/usr -DPython_INCLUDE_DIR:PATH=/usr/include/python3.6m -DPython_FIND_REGISTRY:STRING=NEVER -DPython_NumPy_INCLUDE_DIRS:PATH=/usr/local/lib/python3.6/dist-packages/numpy/core/include -DPython3_EXECUTABLE:PATH=/usr/bin/python3 -DPython3_ROOT_DIR:PATH=/usr -DPython3_INCLUDE_DIR:PATH=/usr/include/python3.6m -DPython3_FIND_REGISTRY:STRING=NEVER -DPython3_NumPy_INCLUDE_DIRS:PATH=/usr/local/lib/python3.6/dist-packages/numpy/core/include -DUVC_DEBUGGING=OFF -DFORCE_LOCAL_LIBUVC_BUILD=OFF -DCMAKE_BUILD_TYPE:STRING=Release

    -- The C compiler identification is GNU 7.5.0
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: /usr/bin/cc - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- FORCE_LOCAL_LIBUVC_BUILD=OFF
    -- Looking for libuvc...
    -- Setting RPATH to /usr/local/lib
    -- Found PythonInterp: /usr/bin/python3 (found version "3.6.9")
    -- Found PythonLibs: /usr/lib/aarch64-linux-gnu/libpython3.6m.so (found version "3.6.9")
    -- Found Cython: /usr/bin/cython
    -- Found NumPy: /usr/include (found version "1.19.5")
    -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1")
    -- Checking for module 'libturbojpeg'
    --   Found libturbojpeg, version 1.5.1
    -- Checking for module 'libusb-1.0'
    --   Found libusb-1.0, version 1.0.21
    -- Performing Test Weak Link MODULE -> SHARED (gnu_ld_ignore) - Success
    _modinit_prefix:PyInit_
    -- Configuring done
    -- Generating done
    CMake Warning:
      Manually-specified variables were not used by the project:

        Python3_EXECUTABLE
        Python3_FIND_REGISTRY
        Python3_INCLUDE_DIR
        Python3_NumPy_INCLUDE_DIRS
        Python3_ROOT_DIR
        Python_FIND_REGISTRY
        Python_INCLUDE_DIR
        Python_NumPy_INCLUDE_DIRS
        Python_ROOT_DIR
        SKBUILD
        UVC_DEBUGGING

    -- Build files have been written to: /tmp/pip-c_bmt_qa-build/_skbuild/linux-aarch64-3.6/cmake-build
    [ 33%] Generating C source uvc_bindings.c

    Error compiling Cython file:
    ------------------------------------------------------------
    ...
            cdef uvc.uvc_frame *uvc_frame = NULL
            #when this is called we will overwrite the last jpeg buffer! This can be dangerous!
            with nogil:
                status = uvc.uvc_stream_get_frame(self.strmh, &uvc_frame, timeout_usec)
            if status == uvc.UVC_ERROR_TIMEOUT:
                raise TimeoutError
                                 ^
    ------------------------------------------------------------

    /tmp/pip-c_bmt_qa-build/pyuvc-source/uvc_bindings.pyx:705:30: undeclared name not builtin: TimeoutError
    CMakeFiles/uvc_bindings.dir/build.make:76: recipe for target 'uvc_bindings.c' failed
    make[2]: *** [uvc_bindings.c] Error 1
    make[2]: *** Deleting file 'uvc_bindings.c'
    CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/uvc_bindings.dir/all' failed
    make[1]: *** [CMakeFiles/uvc_bindings.dir/all] Error 2
    Makefile:135: recipe for target 'all' failed
    make: *** [all] Error 2
    Traceback (most recent call last):
      File "/usr/local/lib/python3.6/dist-packages/skbuild/setuptools_wrap.py", line 649, in setup
        cmkr.make(make_args, install_target=cmake_install_target, env=env)
      File "/usr/local/lib/python3.6/dist-packages/skbuild/cmaker.py", line 686, in make
        self.make_impl(clargs=clargs, config=config, source_dir=source_dir, install_target=install_target, env=env)
      File "/usr/local/lib/python3.6/dist-packages/skbuild/cmaker.py", line 718, in make_impl
        "An error occurred while building with CMake.\n"

    An error occurred while building with CMake.
      Command:
        /usr/bin/cmake --build . --target install --config Release --
      Install target:
        install
      Source directory:
        /tmp/pip-c_bmt_qa-build
      Working directory:
        /tmp/pip-c_bmt_qa-build/_skbuild/linux-aarch64-3.6/cmake-build
    Please check the install target is valid and see CMake's output for more information.

    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-c_bmt_qa-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-0iq83u0w-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-c_bmt_qa-build/
papr commented 1 year ago

@AvinashNargund Hey, few notes:

papr commented 1 year ago

@AvinashNargund Please also try using a newer Python version

AvinashNargund commented 1 year ago

Thanks, will try again with these pointers in mind.