1

Trying to set up a PC with Bloomberg python API. I followed every step of the instruction but when i finally tried to "import blpapi", it always run into issues. Below is the log. Any help would be greatly appreciated.

I did the following steps already, after researching the issue for hours online:

  1. install latest c++ api into c:\blp\cppapi directory
  2. added c:\blp\cppapi\lib, c\blp\cppapi\bin, and c:\blp\cppapi to path
  3. set env BLPAPI_ROOT to c:\blp\cppapi
  4. I even reinstalled Bloomberg.

Still, i always got the same error. Looks like I just can't make python to get to the c++ API directory on the hard drive...

Thanks in advance!

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools>python
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import blpapi
Traceback (most recent call last):
  File "C:\Users\frank\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\blpapi\internals.py", line 39, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1520.0_x64__qbz5n2kfra8p0\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'blpapi._internals'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\frank\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\blpapi\__init__.py", line 6, in <module>
    from .internals import CorrelationId
  File "C:\Users\frank\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\blpapi\internals.py", line 42, in <module>
    _internals = swig_import_helper()
  File "C:\Users\frank\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\blpapi\internals.py", line 41, in swig_import_helper
    return importlib.import_module('_internals')
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1520.0_x64__qbz5n2kfra8p0\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 "<stdin>", line 1, in <module>
  File "C:\Users\frank\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\blpapi\__init__.py", line 11, in <module>
    raise debug_load_error(error)
ImportError:
---------------------------- ENVIRONMENT -----------------------------
Platform: Windows-10-10.0.18362-SP0
Architecture: ('64bit', 'WindowsPE')
Python: 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)]
Python implementation: CPython

blpapi 64-bit will be loaded from: "C:\blp\cppapi\bin\blpapi3_64.dll"
blpapi 32-bit will be loaded from: "C:\blp\cppapi\bin\blpapi3_32.dll"
System PATH: (* marks locations where blpapi was found)
    "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86"
    "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TestWindow"
    "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin\Roslyn"
    "C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86"
    "C:\Program Files (x86)\Windows Kits\10\bin\x86"
    "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\\MSBuild\15.0\bin"
    "C:\Windows\Microsoft.NET\Framework\v4.0.30319"
    "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\"
    "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\"
    "C:\Program Files (x86)\Common Files\Oracle\Java\javapath"
    "C:\WINDOWS\system32"
    "C:\WINDOWS"
    "C:\WINDOWS\System32\Wbem"
    "C:\blp\cppapi"
  * "C:\blp\cppapi\bin"
  * "C:\blp\cppapi\lib"
    "C:\WINDOWS\System32\WindowsPowerShell\v1.0\"
    "C:\WINDOWS\System32\OpenSSH\"
    "C:\Program Files (x86)\AOMEI Backupper"
  * "C:\blp\DAPI"
    "C:\Users\frank\AppData\Local\Microsoft\WindowsApps"
    "C:\blp\cppapi"
  * "C:\blp\cppapi\bin"
  * "C:\blp\cppapi\lib"
  * "C:\blp\DAPI"
    "C:\blp\DAPI\DDE"
    "C:\Program Files\JetBrains\PyCharm Community Edition 2020.2.1\bin"
    "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin"
    "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja"

blpapi package at: "C:\Users\frank\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages"

Current directory: "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"

----------------------------------------------------------------------
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.
>>>
GQDev
  • 11
  • 2

3 Answers3

0

Glad to report this has been solved.

It turned out that I was running Python 3.8, which isn't yet supported. I have to down-version to 3.7.9, and switch to the 'experimental release' of C++ SDK, for this to work.

Hope this can help others too who struggle with this.

GQDev
  • 11
  • 2
0

I would advise against building blpapi yourself, the binaries are available in conda via the conda-forge channel.

conda install -c conda-forge blpapi

There is a build available for python 3.8, so unsure what exactly your issue was but it is possible to build.

mgilbert
  • 3,495
  • 4
  • 22
  • 39
0

Python 3.8 is now supported and I am able to use it.

Even though you have Visual Studio 2017, you may not have the required components to run blpapi commands. So make sure you have the following components. If you dont have them, reinstall and choose them specifically:

  • C++/CLI Support
  • VC++ 2015.3 v14.00 (v140) toolset for desktop
  • Visual C++ MFC for x86 and x64
  • Visual C++ ATL for x86 and x64

If that is not the problem, you can try to copy the .dll files in C++API\lib (blpapi3_32.dll and blpapi3_64.dll in my case) into C:\windows\system32 where all the dll files that system uses. I am not sure if that was part of the solution but I also copied the dll files in in C++API\lib into C:\blp\DAPI, replacing the new ones with the old ones to make sure I have the same dll files everywhere.

Cagri
  • 307
  • 3
  • 13