innobi / pantab

Read/Write pandas DataFrames with Tableau Hyper Extracts
BSD 3-Clause "New" or "Revised" License
114 stars 44 forks source link

Importing tableauhyperapi before pantab makes pantab import fail #390

Open fxstempfelals opened 7 hours ago

fxstempfelals commented 7 hours ago

Describe the bug Importing pantab after tableauhyperapi makes the pantab import fail.

Traceback (most recent call last):
  File "C:\Users\534338\.conda\envs\depot_loc\lib\site-packages\IPython\core\interactiveshell.py", line 3577, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-6-3ad051ba6f0b>", line 2, in <module>
    import pantab
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2024.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\534338\.conda\envs\depot_loc\lib\site-packages\pantab\__init__.py", line 16, in <module>
    from pantab._reader import frame_from_hyper, frame_from_hyper_query, frames_from_hyper
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2024.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\534338\.conda\envs\depot_loc\lib\site-packages\pantab\_reader.py", line 7, in <module>
    import pantab.libpantab as libpantab
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2024.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ImportError: DLL load failed while importing libpantab: The specified procedure could not be found.

To Reproduce Steps to reproduce the behavior:

import tableauhyperapi
import pantab

Expected behavior pantab is imported successfully

Desktop (please complete the following information):

Additional context tableauhyperapi==0.0.18825 pantab==5.1.0

On Unix, the error is: ImportError: /opt/conda/lib/python3.9/site-packages/pantab/libpantab.cpython-39-x86_64-linux-gnu.so: undefined symbol: hyper_numeric_from_float

WillAyd commented 7 hours ago

Thanks for the report. Just to confirm, you've installed the wheels from pypi and have not installed from source correct?

WillAyd commented 7 hours ago

At a high level, the issue is that pantab vendors its own copy of the tableauhyperapi C++ library, which may not necessarily be compatable with others installed on the system. When you do import tableauhyperapi you are loading the copy of the C++ library included with that Python package, and if not instructed otherwise the import pantab call may think it doesn't need to load its own C++ library version. pantab vendors the C++ tableauhyperapi library version 0.0.20027, which must have introduced the hyper_numeric_from_float symbol that is missing from 0.0.18825

The wheels we distributed should correct this issue. We use auditwheel for our Unix wheels, which repacks the wheel and prevents conflicts with the system library. For Windows, we use the delvewheel library, which I think works the same, although I'll admit my knowledge of Windows is pretty limited. If you aren't using a wheel that we have distributed, you may need to run one of these libraries locally to resolve the issue