gpt4 book ai didi

python - 在 python 中为 bloomberg API 安装 blpapi 时出现错误

转载 作者:太空狗 更新时间:2023-10-29 22:10:16 25 4
gpt4 key购买 nike

我是 Bloomberg 终端用户,正在尝试通过 Python 让 API 工作。

我在我的 Windows 7 64 位计算机上安装了 Python 3.7.0 64 位:C:\Users\gp\AppData\Local\Programs\Python\Python37

我从 Bloomberg API 库下载了 C/C++ 支持版本 (v3.8.18.1)。我将内容解压缩到 C:\blp\API\cpp(我是终端用户,所以我已经有了 C:\blp\API 并且我添加了一个新文件夹 “CPP”).

然后我按照本页底部所述通过 pip 安装了 Python API:API Library Support并收到 Successfully installed blpapi-3.12.2 消息。我注意到它已安装到 C:\Users\gp\AppData\Local\Programs\Python\Python37\Lib\site-packages

然后在空闲状态下,我导入 blpapi 并出现以下错误:

Traceback (most recent call last):
File "C:\Users\gp\AppData\Local\Programs\Python\Python37\lib\site-packages\blpapi\internals.py", line 39, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\gp\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 670, in _load_unlocked
File "<frozen importlib._bootstrap>", line 583, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 1043, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed: The specified procedure could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\gp\AppData\Local\Programs\Python\Python37\lib\site-packages\blpapi\__init__.py", line 4, in <module>
from .internals import CorrelationId
File "C:\Users\gp\AppData\Local\Programs\Python\Python37\lib\site-packages\blpapi\internals.py", line 42, in <module>
_internals = swig_import_helper()
File "C:\Users\gp\AppData\Local\Programs\Python\Python37\lib\site-packages\blpapi\internals.py", line 41, in swig_import_helper
return importlib.import_module('_internals')
File "C:\Users\gp\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_internals'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import blpapi
File "C:\Users\gp\AppData\Local\Programs\Python\Python37\lib\site-packages\blpapi\__init__.py", line 9, in <module>
raise debug_load_error(error)
ImportError: No module named '_internals'

Mismatch between C++ and Python SDK libraries.

Python SDK version 3.12.1
Found C++ SDK version 3.11.6.1

Download and install the latest C++ SDK from:

http://www.bloomberg.com/professional/api-library

If a recent version of the C++ SDK is already installed, please ensure that the
path to the library is added to PATH before entering the interpreter.

我在此站点上搜索了答案并尝试了以下操作:

  • 将系统属性中“gp 的用户变量”和“系统变量”中的“路径”变量设置为:C:\blp\DAPI;C:\blp\DAPI\DDE;C:\blp\API\cpp;C:\blp\API\cpp\bin(DAPI 和 DDE 文件夹已经存在)
  • 在系统属性的“gp 用户变量”和“系统变量”中添加了一个“BLPAPI_ROOT”变量:C:\blp\API\cpp
  • 尝试将 C:\blp\API\cpp\bin 文件夹中的 blpapi3_64.dll 副本放入 C:\Users\gp\AppData\Local\Programs\Python\Python37\Lib\site-packages 并尝试将其放在子文件夹“blpapi”中并将这些位置添加到上述路径变量中,但它仍然无效。
  • 确保我已下载 Visual Studio Build Tools 2017

还有其他想法吗?

最佳答案

不匹配的问题是因为你需要下载3.12版本的SDK。目前它对应于您可以在此处找到的“实验版本”(而不是受支持的版本!):

https://www.bloomberg.com/professional/support/api-library/

enter image description here

其他备注:

  1. 我建议您通过彭博终端下载 BloombergWindowsSDK,因为您还会获得 Python 代码。
  2. 无需修改系统路径,只需复制并粘贴 blpapi3_64.dllblpapi3_32.dll 到与您的 python 代码所在的文件夹相同的文件夹。

关于python - 在 python 中为 bloomberg API 安装 blpapi 时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52897576/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com