pysintaller exe文件未运行,引发找不到Hyper API二进制目录错误

问题描述

我创建了一个Python脚本,该脚本使用Tableau Hyper Api创建Tableau(.hyper)提取文件。很大程度上基于Tableau提供的示例脚本。

我正在尝试使用pyinstaller打包。 Pyinstaller“成功”创建了exe,但是当我尝试运行exe时,出现此错误

Traceback (most recent call last):
  File "create_datasource.py",line 3,in <module>
    import tableauhyperapi
  File "<frozen importlib._bootstrap>",line 991,in _find_and_load
  File "<frozen importlib._bootstrap>",line 975,in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>",line 671,in _load_unlocked
  File "C:\Users\user\AppData\Roaming\Python\python38\site-packages\PyInstaller\loader\pyimod03_importers.py",line 493,in exec_module
    exec(bytecode,module.__dict__)
  File "tableauhyperapi\__init__.py",line 126,in <module>
  File "<frozen importlib._bootstrap>",module.__dict__)
  File "tableauhyperapi\catalog.py",line 15,module.__dict__)
  File "tableauhyperapi\connection.py",line 20,module.__dict__)
  File "tableauhyperapi\result.py",line 18,module.__dict__)
  File "tableauhyperapi\date.py",line 14,module.__dict__)
  File "tableauhyperapi\impl\hapi.py",module.__dict__)
  File "tableauhyperapi\impl\dll.py",line 28,in <module>
  File "tableauhyperapi\impl\util.py",line 65,in find_hyper_api_library
RuntimeError: tableauhyperapi.dll library not found. Could not find the Hyper API binary directory,tried C:\Users\user\AppData\Local\Temp\_MEI450082\tableauhyperapi\bin.
[43160] Failed to execute script create_datasource

我尝试将tableauhyperapi.dll作为二进制文件添加到pyinstaller命令中,但是它仍然会引发上述错误

有人可以协助我解决问题吗?

解决方法

您需要专门添加dll,以便将其提取到错误消息倒数第二行中命名的相对文件夹-_MEI450082之后的相对文件夹。

如果您不知道如何执行此操作,请阅读文档pyinstaller.readthedocs.io/en/stable /

基本上,您需要在pyinstaller命令中添加以下内容:

—add-binary “c:\full\path\to\tableauhyperapi.dll;tableauhyperapi/bin”

在该文件开始运行后,可能还会添加其他文件。

,

添加到Barny的答案以及特定于Tableau Hyper API的内容后,您将遇到.bashrc

使用--add-data可以解决该问题。命令:

Could not auto-detect Hyper binary: Hyper binary is not in the expected directory AppData\Local\Temp\_MEI176802\tableauhyperapi\bin\hyper