alliedvision / VimbaPython

Old Allied Vision Vimba Python API. The successor to this API is VmbPy
BSD 2-Clause "Simplified" License
93 stars 40 forks source link

Invalid VimbaC Version error #43

Open sroeyz opened 3 years ago

sroeyz commented 3 years ago

Hello, I downloaded latest VimbaPython, and tried to run the following code through pyCharm:

import cv2 from vimba import *

def print_hi(name):

Use a breakpoint in the code line below to debug your script.

print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.

if name == 'main': print_hi('PyCharm')

with Vimba.get_instance () as vimba:
    cams = vimba.get_all_cameras ()
    with cams [0] as cam:
        frame = cam.get_frame ()
        frame.convert_pixel_format(PixelFormat.Mono8)
        cv2.imwrite('frame.jpg', frame.as_opencv_image ())

I got the following error:

Traceback (most recent call last): File "C:\Users\dlab\PycharmProjects\pythonProject\main.py", line 6, in from vimba import * File "C:\Users\dlab\AppData\Local\Programs\Python\Python39\Scripts\VimbaPython-master\vimba__init__.py", line 103, in from .vimba import Vimba File "C:\Users\dlab\AppData\Local\Programs\Python\Python39\Scripts\VimbaPython-master\vimba\vimba.py", line 30, in from .c_binding import call_vimba_c, VIMBA_C_VERSION, VIMBA_IMAGE_TRANSFORM_VERSION, \ File "C:\Users\dlab\AppData\Local\Programs\Python\Python39\Scripts\VimbaPython-master\vimba\c_binding__init__.py", line 107, in from .vimba_c import VmbInterface, VmbAccessMode, VmbFeatureData, \ File "C:\Users\dlab\AppData\Local\Programs\Python\Python39\Scripts\VimbaPython-master\vimba\c_binding\vimba_c.py", line 674, in _lib_instance = _check_version(_attach_signatures(load_vimba_lib('VimbaC'))) File "C:\Users\dlab\AppData\Local\Programs\Python\Python39\Scripts\VimbaPython-master\vimba\c_binding\vimba_c.py", line 664, in _check_version raise VimbaSystemError(msg.format(EXPECTED_VIMBA_C_VERSION, VIMBA_C_VERSION)) vimba.error.VimbaSystemError: Invalid VimbaC Version: Expected: 1.8.3, Found:1.8.2

NiklasKroeger-AlliedVision commented 3 years ago

VimbaPython is essentially a wrapper around our VimbaC API. This is distributed as part of our Vimba SDK, which you have installed on your system. As VimbaPython simply performs its operations by calling out to VimbaC, the versions of these two modules have to be verified together. For that reason a check is implemented, that verifies that VimbaPython found the expected version of VimbaC as those were validated together by us.

The problem you are seeing is that the Version of Vimba you have installed on your system is older than the version VimbaPython expects. To ensure compatibility it would be best, if you upgraded your Vimba installation to the current version Vimba4.2 This includes the expected VimbaC version 1.8.3. You can find a download link to our most current Vimba version on our website.

If you cannot upgrade your Vimba installation you may also go ahead and install the VimbaPython version that is provided with your Vimba package. You will find it in your Vimba installation directory (usually located in C:\Program Files\Allied Vision\Vimba_X.Y\VimbaPython\Source where X.Y is the Vimba version - in your case I assume 4.1). This version is is not the most up to date VimbaPython, but it is validated with the provided VimbaC version.

Lastly if you really want to use the newest VimbaPython with your non-latest Vimba installation, you may change the EXPECTED_VIMBA_C_VERSION for your VimbaPython installation in VimbaPython/vimba/c_binding/vimba_c.py. By doing so however you would be using a non-validated combination of these two APIs. While there are only minor differences in these versions, please be advised that this approach is not recommended!

sroeyz commented 3 years ago

Thanks for the quick reply! I updated Vimba to 4.2, and after restart a get another error with the script above:

Traceback (most recent call last): File "C:\Users\dlab\PycharmProjects\pythonProject\main.py", line 6, in from vimba import * File "C:\Users\dlab\AppData\Local\Programs\Python\Python39\Scripts\VimbaPython-master\vimba\vimba.py", line 30, in from .c_binding import call_vimba_c, VIMBA_C_VERSION, VIMBA_IMAGE_TRANSFORM_VERSION, \ ImportError: attempted relative import with no known parent package

NiklasKroeger-AlliedVision commented 3 years ago

That error is very unexpected and I have not yet experienced it myself. Could you please try to run one of our included examples from the vimbaPython repository? list_cameras.py is usually a good candidate to check if the Vimba installation was successful.

If that does not work I am afraid the next step would be to uninstall VimbaPython and try to install it again from a fresh checkout. Just to be sure, that file permissions did not change and the files contain the expected code.

honkomonk commented 3 years ago

The message: ImportError: attempted relative import with no known parent package hints to a broken package installation. It gets raised if you try to from .<module> import yx but you're already at the top level of a module. Therefore "no known parent".

@sroeyz : How exactly did you install the module? You have to cd into the directory Niklas mentioned (C:\Program Files\Allied Vision\Vimba_X.Y\VimbaPython\Source; you should see a setup.py) and execute pip install . there. If you copy the directory or bend the sys.path to you will, it could be the source of the problem, if not done correctly.