When importing Bloomberg’s
blpapi package using PyXLL, you may encounter the following error:
ImportError: No module named '_internals'
Mismatch between C++ and Python SDK libraries.
Python SDK version 3.12.1
Found C++ SDK version 188.8.131.52
Download and install the latest C++ SDK from:
This is because both the Bloomberg Python API and the Bloomberg Excel Add-In are loading the same Bloomberg C++ SDK, but they require different versions.
This is a problem with how Bloomberg’s Python API is built. Bloomberg are aware of the issue but have not yet provided a solution. Fortunately there are a couple of work-arounds you can use in the meantime.
- Download a fork of blpapi with a fix for this problem
- Build the Bloomberg Python API with the matching C++ SDK
Download a fork of blpapi with a fix for this problem
As this is a common problem, we have put a fork of Bloomberg’s Python API on github that includes a fix for this problem.
You can either build it from source, or use one of the pre-built releases.
To install one of the pre-built releases:
Download the latest .whl file for your version of Python from https://github.com/pyxll/blpapi-python/releases.
Uninstall any previous version by running:
pip uninstall blpapi
If you are using Anaconda, also run
conda uninstall blpapi.
Install the .whl file downloaded previously by running:
pip install "downloaded .whl filename"
To install from source clone the repo from https://github.com/pyxll/blpapi-python and follow the instructions in the README file.
Build the Bloomberg Python API with the matching C++ SDK
If you would rather use the official Bloomberg Python API you will need to build it yourself against the same version of the Bloomberg C++ SDK that your Bloomberg Excel Add-In was built using.
- Make a note of the version of the C++ SDK from the error message that is printed when trying to import the blpapi package.
- Download that version of the C++ SDK from Bloomberg’s website.
- Build the Bloomberg Python API using that C++ SDK.
- Ensure that any previously installed versions of the blpapi package are uninstalled and install the one just built.