0

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.
Chan
  • 3,605
  • 9
  • 29
  • 60

3 Answers3

1

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.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Cagri
  • 307
  • 3
  • 13
0

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

Mourad Barakat
  • 661
  • 3
  • 6
  • where would one specifically go to set this "BLPAPI_ROOT environment variable" ? – user2662565 Apr 23 '19 at 17:04
  • @user2662565 This does not deserve a downvote just because you do not know how to set an environment variable... Just google setting environment variables. – mgilbert Apr 24 '19 at 01:56
  • ok well I learned that I needed to actually create a new environment variable called "BLPAPI_ROOT" (not specified above), and set the path to wherever the C++ SDK file is located. This, still ,does not resolve things. the C++ SDK version needs to be the same as the Python SDK, but moreover, creating and setting the environment variable BLPAPI_ROOT still fails in my case (using Spyder), because for whatever reason Python is finding C++ SDK Version 3.11.xx and Python SDK is 3.12.3. – user2662565 May 01 '19 at 16:49
0

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

mgilbert
  • 3,495
  • 4
  • 22
  • 39
  • this is false. I installed via conda and it did not resolve my issue. I was able to successfully install blpapi via python -m pip install --index-url=https://bloomberg.bintray.com/pip/simple blpapi, but still am unable to import pdblp nor blpapi into spyder – user2662565 Apr 23 '19 at 17:06
  • This is not false... you may have had a different issue but it's impossible to know since you have responded with a comment and posted no information about your situation. Using conda does resolve issues related to improperly set environment variables since this is handled by the package maintainer instead of by the user at install time. You indicated "I was able to successfully install blpapi" but cannot import the library... which does not sound like a successful install. Also I don't see how `pdblp` or `spyder` are relevant here? – mgilbert Apr 24 '19 at 01:53