Python 2.7 with Bloomberg API import blpapi failure

依然范特西╮ 提交于 2019-11-29 13:40:30

I encountered a similar problem, and spent some time troubleshooting the issue with Bloomberg helpdesk. Here's what I learnt:

The ImportError is the result of Bloomberg not being able to find the "blpapi3_32.dll" DLL file. This DLL file can be located under the \bin or \lib folder of Bloomberg's C/C++ library, which is at the same location where you got your Python executable. So go download that library (v3.7.5.1 as of this writing), and have your system's "Path" environment variable include that location. This should resolve the issue.

PS you can access the PATH variable via Start > right-clicking "Computer" > Properties > Advanced System Settings > Advanced (tab) > Environment Variables > look for the "Path" variable under "System variables". Edit this variable to include the location of the DLL file, e.g. if the original Path variable is "C:\Python27\Lib\site-packages\PyQt4", then new Path variable should be "C:\Python27\Lib\site-packages\PyQt4;C:\blp\API\blpapi_cpp_3.7.5.1\bin"

Note this article, from Bloomberg:

In order for python scripts to call Bloomberg API functions, the libraries distributed as part of the Bloomberg C++ SDK must be available to the Python interpreter. Step 3 of installation, above, provides system-wide installation of this library. Linux/Solaris/*nix users without system-wide installations must set the LD_LIBRARY_PATH (or DYLD_LIBRARY_PATH on Darwin/MacOS X) environment variable to include the directory containing the blpapi3 shared libraries. Windows users may need to set the PATH variable to the directory containing blpapi3_32.dll or blpapi3_64.dll. (Note that Windows users with the Bloomberg Terminal software installed already have versions of these libraries in their PATH.)

So what I did (very similarly to Keng Onn's answer) was:

  1. Download the C/C++ lib for Windows

  2. Extract files from blpapi_cpp_3.8.8.1.zip (or similar)

  3. Copy blpapi3_32.dll from the bin folder and paste it anywhere safe

In my case, I pasted it into C:\Python27\Lib\site-packages\blpapi

  1. Add this route to your Path environment variable

    • Click "Start" / Right-click "Computer" / Properties / Advanced System Settings / Advanced tab / Environment Variables

    • Double click "Path" under "System variables" list

    • Add a semicolon (;) and your path as seen below

For me: C:\Python27\Lib\site-packages\blpapi

Now it should work just fine for you. Hope it helps.

I had the same issue, which was simply solved after updating the Bloomberg terminal application.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!