blpapi模块的导入错误

时间:2018-07-10 18:13:13

标签: python python-3.6 bloomberg blpapi

这是我的第一篇文章。我运行以下命令: 赢10 使用Python 3.6.5的Anaconda 彭博资讯

我正在尝试将blpapi(bloomberg专业API)用于Python。下载了Desktop API软件包(带有C ++库),下载了blpapi-3.9.1-cp36-cp36m-win_amd64.whl安装程序文件并成功运行了该文件。最后,我在用户变量和环境变量中都将C:\..\C++API\v3.11.6.1\bin添加到了我的路径中(来自此处关于stackoverflow的早期查询): Python 2.7 with Bloomberg API import blpapi failure

运行import blpapi时出现的错误消息:

>---------------------------------------------------------------------------
>ImportError                               Traceback (most recent call last)
>~\Anaconda3\lib\site-packages\blpapi\internals.py in swig_import_helper()
>     38         try:
>---> 39             return importlib.import_module(mname)
>     40         except ImportError:
>
>~\Anaconda3\lib\importlib\__init__.py in import_module(name, package)
>    125             level += 1
>--> 126     return _bootstrap._gcd_import(name[level:], package, level)
>    127 >>
>
>~\Anaconda3\lib\importlib\_bootstrap.py in _gcd_import(name, package, level)
>
>~\Anaconda3\lib\importlib\_bootstrap.py in _find_and_load(name, import_)
>
>~\Anaconda3\lib\importlib\_bootstrap.py in _find_and_load_unlocked(name, >import_)
>
>~\Anaconda3\lib\importlib\_bootstrap.py in _load_unlocked(spec)
>
>~\Anaconda3\lib\importlib\_bootstrap.py in module_from_spec(spec)
>
>~\Anaconda3\lib\importlib\_bootstrap_external.py in create_module(self, spec)
>
>~\Anaconda3\lib\importlib\_bootstrap.py in _call_with_frames_removed(f, *args, >**kwds)
>
>ImportError: DLL load failed: The specified module could not be found.
>
>During handling of the above exception, another exception occurred:
>
>ModuleNotFoundError                       Traceback (most recent call last)
>~\Anaconda3\lib\site-packages\blpapi\__init__.py in <module>()
>      3 try:
>----> 4     from .internals import CorrelationId
>      5 except ImportError as error:
>
>~\Anaconda3\lib\site-packages\blpapi\internals.py in <module>()
>     41             return importlib.import_module('_internals')
>---> 42     _internals = swig_import_helper()
>     43     del swig_import_helper
>
>~\Anaconda3\lib\site-packages\blpapi\internals.py in swig_import_helper()
>     40         except ImportError:
>---> 41             return importlib.import_module('_internals')
>     42     _internals = swig_import_helper()
>
>~\Anaconda3\lib\importlib\__init__.py in import_module(name, package)
>    125             level += 1
>--> 126     return _bootstrap._gcd_import(name[level:], package, level)
>    127 
>
>ModuleNotFoundError: No module named '_internals'
>
>During handling of the above exception, another exception occurred:
>
>ImportError                               Traceback (most recent call last)
><ipython-input-1-ee203a799ece> in <module>()
>----> 1 import blpapi
>
>~\Anaconda3\lib\site-packages\blpapi\__init__.py in <module>()
>     27 
>     28 """ % (str(error), env)
>---> 29     raise ImportError(msg)
>     30 
>     31 from .abstractsession import AbstractSession
>
>ImportError: No module named '_internals'
>
>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.

有人知道可能是什么问题吗?

2 个答案:

答案 0 :(得分:1)

有完全相同的问题。 可比性问题。

对我来说,解决方案是将python版本回滚到 3.7.7 64位

from: 3.8.3 32-bit
to: 3.7.7 64-bit

如果版本兼容,则BLPAPI可以工作,否则它们将失败。

彭博dll文件:

blpapi3_32.dll (version 3.14.3.1)
blpapi3_64.dll (version 3.14.3.1)

这解决了问题。

答案 1 :(得分:0)

已解决:我安装了Microsoft Build Tools 2017,并按照原始帖子中链接问题中的描述添加了BLPAPI_ROOT路径。