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

Python requires different C-Version of Vimba? #28

Closed beniroquai closed 3 years ago

beniroquai commented 3 years ago

Today we installed the recent Vimba SDK (including all necessary libraries). After installing VimbaPython, the following error occurs:

>>> import vimba
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\UC2\Anaconda3\lib\site-packages\vimba\__init__.py", line 103, in <module>
    from .vimba import Vimba
  File "C:\Users\UC2\Anaconda3\lib\site-packages\vimba\vimba.py", line 30, in <module>
    from .c_binding import call_vimba_c, VIMBA_C_VERSION, VIMBA_IMAGE_TRANSFORM_VERSION, \
  File "C:\Users\UC2\Anaconda3\lib\site-packages\vimba\c_binding\__init__.py", line 107, in <module>
    from .vimba_c import VmbInterface, VmbAccessMode, VmbFeatureData, \
  File "C:\Users\UC2\Anaconda3\lib\site-packages\vimba\c_binding\vimba_c.py", line 674, in <module>
    _lib_instance = _check_version(_attach_signatures(load_vimba_lib('VimbaC')))
  File "C:\Users\UC2\Anaconda3\lib\site-packages\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

Is there a way to match the installed VimbaC version with the expected version from Python?

Thanks for your help!

NiklasKroeger-AlliedVision commented 3 years ago

Today we installed the recent Vimba SDK (including all necessary libraries).

I assume this is Vimba 4.2 which is the current release available for download from our website. Is that correct?

Is there a way to match the installed VimbaC version with the expected version from Python?

The version check for the VimbaC dll that is detected is performed to ensure that only library versions which have been validated together are used together. This is always the case for VimbaC and VimbaPython versions installed from the same release. Since from your description this seems to be the case for you, the error is definitely unexpected!

vimba.error.VimbaSystemError: Invalid VimbaC Version: Expected: 1.8.3, Found:1.8.2

The error indicates, that an older version of VimbaC is picked up by VimbaPython than expected. VimbaC 1.8.2 was included in the Vimba 4.1 package. So I assume, that you had this installed on your machine previously? If so, it seems like this installation was not removed prior to installing Vimba 4.2 and is still picked up, most likely due to non-refreshed environment variables.

VimbaPython determines the search path for the VimbaC library on Windows systems, by looking at the content of the VIMBA_HOME environment key. On my system this points to the expected Vimba 4.2 installation directory. You can check this for example from the cmd terminal:

C:\Users\nkroeger>echo %VIMBA_HOME%
C:\Program Files\Allied Vision\Vimba_4.2\

This would show you what VimbaPython starts working with. To see the data currently written to the variable you can use the "Edit environment variable" entry of the control panel. To start this simply run

rundll32.exe sysdm.cpl,EditEnvironmentVariables

in a cmd prompt. If you wish to modify the system wide environment variables you need to run this from an elevated cmd prompt (started with administrator rights). image The entries at the top show variables set only for your current user (username is indicated above), while the bottom entries show the system wide variables. VIMBA_HOME should be found here (selected entry in the screenshot).

From the VIMBA_HOME directory VimbaPython moves into VimbaC/Bin/Win64 (or Win32 as determined for your system architecture) to find the VimbaC library. Starting from an incorrect VIMBA_HOME directory would therefore lead to an outdated VimbaC library file and to the error you are experiencing.

As environment variables are not necessarily reloaded after they are changed while the system is running and logged in, your VIMBA_HOME entry might still be pointing to the installation directory of Vimba 4.1. A reboot would ensure, that the environment variables are updated for you.

If even after a reboot the incorrect VimbaC version is still being picked up, something went wrong with the installation of Vimba 4.2. I would suggest you remove your current installation of Vimba and ensure, that the VIMBA_HOME environment key is empty, and no incorrect paths are included in the GENICAM_GENTL64_PATH and GENICAM_GENTL32_PATH variables. Afterwards you can install Vimba 4.2 which should hopefully set these environment variables correctly.

Another issue might be, that the VIMBA_HOME environment key is not only set as a system wide environment variable, but also as a variable for your user. I assume the user set one would take precedence over the system wide one, but I never checked this. So you could also check if the VIMBA_HOME variable is set as a user variable as well.

beniroquai commented 3 years ago

Thanks a lot! This solved the problem. For some reason, the system variable was not updated. I did

set VIMBA_HOME=C:\Program Files\Allied Vision\Vimba_4.2

now I can import vimba with no problems! Brilliant!

NiklasKroeger-AlliedVision commented 3 years ago

That is great to hear.

Just as an additional note because you did not mention it. Maybe you should also take a look at the GENICAM_GENTL64_PATH and GENICAM_GENTL32_PATH (if you need 32bit support) variables. If VIMBA_HOME was not updated correctly perhaps these were also not changed and your Vimba installation would pick up the old Transport Layer .cti files. This is generally not a problem and you can most likely use your cameras as expected but if you install Vimba 4.2 you would of course expect to also use the transport layers released with that version.