Install error for blpapi in python for bloomberg A

2020-02-09 12:15发布

I am a Bloomberg terminal user and am trying to get the API to work via Python.

I have Python 3.7.0 64-bit on my Windows 7 64-bit computer installed to: C:\Users\gp\AppData\Local\Programs\Python\Python37

I downloaded the C/C++ Supported Release (v3.8.18.1) from the Bloomberg API Library. I unzipped contents to C:\blp\API\cpp (I am a terminal user so I already had C:\blp\API and I added a new folder "CPP").

I then installed the Python API through pip as stated at the bottom of this page: API Library Support and received a Successfully installed blpapi-3.12.2 message. I noticed this got installed to C:\Users\gp\AppData\Local\Programs\Python\Python37\Lib\site-packages

In Idle I then import blpapi and I get the following errors:

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.

I searched through answers on this site and attempted the following:

  • set the 'path' variable in both "User variables for gp" and "system variables" in system properties to: C:\blp\DAPI;C:\blp\DAPI\DDE;C:\blp\API\cpp;C:\blp\API\cpp\bin (DAPI and DDE folders were already there)
  • added a 'BLPAPI_ROOT' variable of: C:\blp\API\cpp in the "User variables for gp" and "system variables" in system properties
  • tried placing a copy of blpapi3_64.dll from the C:\blp\API\cpp\bin folder into C:\Users\gp\AppData\Local\Programs\Python\Python37\Lib\site-packages and tried placing it in subfolder "blpapi" and added those locations to the path variable mentioned above and it still did not work.
  • ensured I have downloaded Visual Studio Build Tools 2017

Any other ideas?

11条回答
Animai°情兽
2楼-- · 2020-02-09 12:43

For 3.7 on windows I had to use the 3.31.1 version of the C\C++ library. It was marked as experimental but Bloomberg but it allowed me to import it successfully.

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2020-02-09 12:46

The problem of mismatch comes from the fact that you need to download version 3.12 of the SDK. Currently it corresponds to the "Experimental release" (and not Supported release !) that you can find here:

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

enter image description here

Other remarks:

  1. I advice you to download the BloombergWindowsSDK via the Bloomberg Terminal because you'll get python codes also.
  2. No needs to play with system path, you can just copy and past blpapi3_64.dll blpapi3_32.dll to the same folder as the one where your python code is located.
查看更多
放荡不羁爱自由
4楼-- · 2020-02-09 12:46

Running Windows 10 and Python 3.7.5.

I downloaded the experimental release here https://www.bloomberg.com/professional/support/api-library/ as suggested by other people already.

I was still getting an error though when I tried to run import blpapi.

I solved this by adding C:\blpapi_cpp_3.13.1.1\bin to my PATH environment variable. Apparently the system couldn't find the DLL files for the C++ SDK and needs a direct path to the folder.

查看更多
倾城 Initia
5楼-- · 2020-02-09 12:47

Check which folder is in your environment path. Sometimes people have two blp folders in system path, i.e. both C:\blp\DAPI and C:\BloombergWindowsSDK\C++API\v3.12.3.1\lib, make sure you have latest blpapi3_32.dll and blpapi3_64.dll in both file.

查看更多
贼婆χ
6楼-- · 2020-02-09 12:50

Actually the clue is hidden at the end of the error message, but it wasn't entirely clear.

You need to download the Bloomberg C++ library as well. Unzip into a folder, let's call it c:\lib\blpapi_cpp_3.12.2.1

What you need to do is add c:\lib\blpapi_cpp_3.12.2.1\lib into you PATH environment variable. The important bit is to include the lib sub folder.

This solved my issue with python 3.7.

查看更多
登录 后发表回答