Chan
Chan

Reputation: 4291

Cannot import bloomberg api

I have installed the bloomberg Python API and set the BLPAPI_ROOT to the VC++ folder.

However, when I import blpapi, I got the following error.

How to get rid of these errors?

Thank you very much.

import blpapi
Traceback (most recent call last):
  File "C:\Users\user\AppData\Roaming\Python\Python36\site-packages\blpapi\internals.py", line 39, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Program Files\WinPython-64bit-3.6.2.0Qt5\python-3.6.2.amd64\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 648, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 560, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 205, 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\user\AppData\Roaming\Python\Python36\site-packages\blpapi\__init__.py", line 4, in <module>
    from .internals import CorrelationId
  File "C:\Users\user\AppData\Roaming\Python\Python36\site-packages\blpapi\internals.py", line 42, in <module>
    _internals = swig_import_helper()
  File "C:\Users\user\AppData\Roaming\Python\Python36\site-packages\blpapi\internals.py", line 41, in swig_import_helper
    return importlib.import_module('_internals')
  File "C:\Program Files\WinPython-64bit-3.6.2.0Qt5\python-3.6.2.amd64\lib\importlib\__init__.py", line 126, 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\user\AppData\Roaming\Python\Python36\site-packages\blpapi\__init__.py", line 9, in <module>
    raise debug_load_error(error)
ImportError: 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.

Upvotes: 0

Views: 3500

Answers (3)

Cagri
Cagri

Reputation: 307

I did 2 things to solve an issue similar to that:

1- I installed Microsoft Visual Studio with the following components

  • 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

2- I manually copied 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.

Also, I copied the dll files in in C++API\lib into C:\blp\DAPI, replacing the new ones with the old ones.

Upvotes: 1

mgilbert
mgilbert

Reputation: 3645

An alternative option is to use conda, as discussed here and here.

If you use conda you don't need to worry about downloading the C++ SDK and properly configuring the BLPAPI_ROOT. From the conda-forge channel this can be done using

conda install -c conda-forge blpapi

Upvotes: 0

Mourad Barakat
Mourad Barakat

Reputation: 671

Please set BLPAPI_ROOT environment variable to the location where the blpapi C++ SDK is located.

Upvotes: 0

Related Questions