nimi-python icon indicating copy to clipboard operation
nimi-python copied to clipboard

Calling nidmm.Session.read() prior to initializing a switch causes "undefined symbol: niSwitch_InitWithTopology" on Linux

Open ni-jfitzger opened this issue 4 years ago • 0 comments

Description of issue

Running the following code on CentOS 7.6 results in an unexpected traceback:

import niswitch
import nidmm
with nidmm.Session("PXI1Slot2", reset_device=True, options={
    'simulate': True, 'driver_setup': { 'Model': '4070', 'BoardType': 'PXI'}}) as dmmS:
    dmmS.configure_measurement_digits(nidmm.Function.TWO_WIRE_RES, -1, 5.5)
    dmmS.read()
    with niswitch.Session('', '2737/2-Wire 4x64 Matrix', True, True) as bridgeS:
        pass
    pass

Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
  File "/home/nitest/ni_venv35/lib64/python3.5/site-packages/niswitch/session.py", line 1454, in __init__
    self._vi = self._init_with_topology(resource_name, topology, simulate, reset_device)
  File "/home/nitest/ni_venv35/lib64/python3.5/site-packages/niswitch/session.py", line 2165, in _init_with_topology
    error_code = self._library.niSwitch_InitWithTopology(resource_name_ctype, topology_ctype, simulate_ctype, reset_device_ctype, None if vi_ctype is None else (ctypes.pointer(vi_ctype)))
  File "/home/nitest/ni_venv35/lib64/python3.5/site-packages/niswitch/_library.py", line 216, in niSwitch_InitWithTopology
    self.niSwitch_InitWithTopology_cfunc = self._library.niSwitch_InitWithTopology
  File "/opt/rh/rh-python35/root/usr/lib64/python3.5/ctypes/__init__.py", line 355, in __getattr__
    func = self.__getitem__(name)
  File "/opt/rh/rh-python35/root/usr/lib64/python3.5/ctypes/__init__.py", line 360, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: python: undefined symbol: niSwitch_InitWithTopology

If the order is changed, the error does not occur:

import niswitch
import nidmm
with niswitch.Session('', '2737/2-Wire 4x64 Matrix', True, True) as bridgeS:
    with nidmm.Session("PXI1Slot2", reset_device=True, options={
        'simulate': True, 'driver_setup': { 'Model': '4070', 'BoardType': 'PXI'}}) as dmmS:
        dmmS.configure_measurement_digits(nidmm.Function.TWO_WIRE_RES, -1, 5.5)
        dmmS.read()
    pass

This behavior has been confirmed on CentOS 7.6 with python 3.5.1 and python 3.6.9. These are installed via software collections as below:

yum install centos-release-scl
yum install rh-python36 rh-python36-python-virtualenv
scl enable rh-python36 bash

The error does not occur on Windows 10 x64 with python 3.6 or python 3.7.

System report

From the python 3.6.9 virtualenv:

python -c "import niswitch; import nidmm; niswitch.print_diagnostic_information(); nidmm.print_diagnostic_information()"" output

```
OS:
    Name:      Linux
    Version:   #1 SMP Thu Nov 29 14:49:43 UTC 2018
    Bits:      64
Driver:
    Name:      NI-SWITCH
    Version:   Unknown
Module:
    Name:      niswitch
    Version:   1.3.0
Python:
    Version:   3.6.9 (default, Nov 11 2019, 11:24:16) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
    Bits:      64
    Is_Venv:   True
    Installed Packages:
        zipp==3.1.0
        wcwidth==0.2.3
        six==1.15.0
        setuptools==36.5.0
        pytest==5.4.3
        pyparsing==2.4.7
        py==1.8.1
        pluggy==0.13.1
        pip==9.0.1
        packaging==20.4
        niswitch==1.3.0
        nidmm==1.3.0
        more-itertools==8.3.0
        importlib-metadata==1.6.0
        hightime==0.2.0
        attrs==19.3.0
OS:
    Name:      Linux
    Version:   #1 SMP Thu Nov 29 14:49:43 UTC 2018
    Bits:      64
Driver:
    Name:      NI-DMM
    Version:   Unknown
Module:
    Name:      nidmm
    Version:   1.3.0
Python:
    Version:   3.6.9 (default, Nov 11 2019, 11:24:16) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
    Bits:      64
    Is_Venv:   True
    Installed Packages:
        zipp==3.1.0
        wcwidth==0.2.3
        six==1.15.0
        setuptools==36.5.0
        pytest==5.4.3
        pyparsing==2.4.7
        py==1.8.1
        pluggy==0.13.1
        pip==9.0.1
        packaging==20.4
        niswitch==1.3.0
        nidmm==1.3.0
        more-itertools==8.3.0
        importlib-metadata==1.6.0
        hightime==0.2.0
        attrs==19.3.0
```

Steps to reproduce issue

See the example code in the description.

ni-jfitzger avatar Jun 04 '20 18:06 ni-jfitzger