无法导入Bloomberg API

时间:2018-11-26 11:45:36

标签: python bloomberg

我已经安装了Bloomberg Python API,并将BLPAPI_ROOT设置为VC ++文件夹。

但是,当我导入blpapi时,出现以下错误。

如何摆脱这些错误?

非常感谢您。

import blpapi
Traceback (most recent call last):
  File "C:\Users\user\AppData\Roaming\Python\Python36\site-packages\blpapi\internals.py", line 39, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Program Files\WinPython-64bit-3.6.2.0Qt5\python-3.6.2.amd64\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 648, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 560, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 205, 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\user\AppData\Roaming\Python\Python36\site-packages\blpapi\__init__.py", line 4, in <module>
    from .internals import CorrelationId
  File "C:\Users\user\AppData\Roaming\Python\Python36\site-packages\blpapi\internals.py", line 42, in <module>
    _internals = swig_import_helper()
  File "C:\Users\user\AppData\Roaming\Python\Python36\site-packages\blpapi\internals.py", line 41, in swig_import_helper
    return importlib.import_module('_internals')
  File "C:\Program Files\WinPython-64bit-3.6.2.0Qt5\python-3.6.2.amd64\lib\importlib\__init__.py", line 126, 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 "<stdin>", line 1, in <module>
  File "C:\Users\user\AppData\Roaming\Python\Python36\site-packages\blpapi\__init__.py", line 9, in <module>
    raise debug_load_error(error)
ImportError: No module named '_versionhelper'

Could not open the C++ SDK library.

Download and install the latest C++ SDK from:

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

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

3 个答案:

答案 0 :(得分:1)

我做了两件事来解决类似的问题:

1-我安装了具有以下组件的Microsoft Visual Studio

  • C ++ / CLI支持
  • 用于桌面的VC ++ 2015.3 v14.00(v140)工具集
  • 用于x86和x64的Visual C ++ MFC
  • x86和x64的Visual C ++ ATL

2-我将C ++ API \ lib中的.dll文件(在我的情况下为blpapi3_32.dll和blpapi3_64.dll)手动复制到C:\ windows \ system32,系统使用了所有dll文件。

此外,我将C ++ API \ lib中的dll文件复制到C:\ blp \ DAPI中,将新文件替换为旧文件。

答案 1 :(得分:0)

请将BLPAPI_ROOT环境变量设置为blpapi C ++ SDK所在的位置。

答案 2 :(得分:-1)

另一种选择是使用conda,如herehere所述。

如果您使用conda,则无需担心下载C ++ SDK和正确配置BLPAPI_ROOT。在conda-forge频道中,可以使用

conda install -c conda-forge blpapi