3
votes

I am trying to get set up with the Bloomberg Python API. I have been following along with this tutorial. I am able to successfully python -m pip install — index-url=https://bloomberg.bintray.com/pip/simple blpapi, but then when I try to run import blpapi in the Python interpreter, I get the following error. How do I resolve this error (wondering if it has something to due with me using Python 3.8)?

ImportError:
---------------------------- ENVIRONMENT -----------------------------
Platform: Windows-10-10.0.17763-SP0
Architecture: ('32bit', 'WindowsPE')
Python: 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)]
Python implementation: CPython

blpapi 64-bit will be loaded from: "C:\blp\API\blpapi_cpp_3.13.1.1\lib\blpapi3_64.dll"
blpapi 32-bit will be loaded from: "C:\blp\API\blpapi_cpp_3.13.1.1\lib\blpapi3_32.dll"
System PATH: (* marks locations where blpapi was found)
    "C:\Windows\system32"
    "C:\Windows"
    "C:\Windows\System32\Wbem"
    "C:\Windows\System32\WindowsPowerShell\v1.0\"
    "C:\Windows\System32\OpenSSH\"
    "C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL"
    "C:\Program Files\Intel\Intel(R) Management Engine Components\DAL"
    "c:\nx_dll"
    "C:\Program Files\nodejs\"
  * "C:\blp\API\blpapi_cpp_3.13.1.1\lib"
    "C:\Program Files\MiKTeX 2.9\miktex\bin\x64\"
    "C:\Users\cpage\AppData\Local\Programs\Python\Python38-32\Scripts\"
    "C:\Users\cpage\AppData\Local\Programs\Python\Python38-32\"
    "C:\Users\cpage\AppData\Local\Microsoft\WindowsApps"
  * "C:\blp\DAPI"
    "C:\blp\DAPI\DDE"
    "C:\Users\cpage\AppData\Roaming\npm"
    "C:\Program Files\Sublime Text 3"
    "C:\Users\cpage\AppData\Local\hyper\app-3.0.2\resources\bin"
    "C:\Users\cpage\AppData\Local\Programs\Microsoft VS Code\bin"
  * "C:\blp\API\blpapi_cpp_3.13.1.1\lib"

blpapi package at: "C:\Users\cpage\AppData\Local\Programs\Python\Python38-32\lib\site-packages"

Current directory: "C:\Users\cpage"

----------------------------------------------------------------------
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
There are several similar questions: stackoverflow.com/… One of them mentions creating an environment variable: BLPAPI_ROOT. - assylias
Yes, I have already set BLPAPI_ROOT to be `C:\blp\API\blpapi_cpp_3.13.1.1`. - cpage
Running through the same problem on Python 3.8 and blpapi_cpp_3.14.3.1 - gt6989b
@gt6989b I'm also trying to use blpapi with Python 3.8. Tried by using pip to install it and by building from source (after setting BLPAPI_ROOT) from blpapi 3.14.3.1, blpapi 3.13.3.1, blpapi 3.12.3.1 and blpapi 3.12.2.1 but none of them seem to work. The error message is almost always the same (Import Error) - raphaeldavidf
@gt6989b the new version works on 3.8, give it a try - raphaeldavidf

3 Answers

3
votes

You need to download the python blpapi package having the version matching your C++ lib.

In your case, since your C++ lib is 3.13.1.1, you can download the 3.13.1 python package:

pip install --index-url=https://bloomberg.bintray.com/pip/simple blpapi==3.13.1

2
votes

Just managed to make it run using version blpapi-3.15.2 using C++ API blpapi_cpp_3.15.0.1

To install run:

python -m pip install --index-url=https://bloomberg.bintray.com/pip/simple blpapi

to import use:

import os
with os.add_dll_directory('<...>\blpapi_cpp_3.15.0.1\lib'):
    import blpapi

or add '<...>\blpapi_cpp_3.15.0.1\lib' to PATH

1
votes

The following procedure works out of the box for CPython 2.7 and 3.7. A Bloomberg rep claims he verified it for CPython 3.5 as well:

  1. Download the C++ BLP API from the official Bloomberg repository. If this link breaks, use Bloomberg API Support homepage to find the up-to-date ones.
  2. Unpack the archive to C:\Programs\blpapi_cpp_3.14.3.1
  3. Exit from the shell.
  4. Set the environment variable BLPAPI_ROOT=C:\Programs\blpapi_cpp_3.14.3.1\. Note that the trailing slash is important.
  5. Start a new shell.
  6. Execute python -m pip install --index-url=https://bloomberg.bintray.com/pip/simple blpapi==3.14.0
  7. Check the installation by executing python -c "import blpapi", which should pass without displaying messages.