5

I am currently using Python 2.7 and my OS is Windows 7. While attempting to use the Bloomberg API I am getting this error:

Traceback (most recent call last):
   File "datagrab.py", line 1, in <module>
     import blpapi, time, json
   File "C:\Python27\lib\blpapi\__init__.py", line 5, in <module>
     from .internals import CorrelationId
   File "C:\Python27\lib\blpapi\internals.py", line 50, in <module>
     _internals = swig_import_helper()
   File "C:\Python27\lib\blpapi\internals.py", line 42, in swig_import_helper
     import _internals
   ImportError: No module named _internals

I have set my path variable to point to blpapi3_64.dll and also updated my bloomberg terminal. I have also moved the local blpapi API to a different directory but still the problem exists.

I am kind of new to this API in general. So can someone please guide me?

Thank you in advance!

Bumblebee9898
  • 71
  • 1
  • 6

2 Answers2

1

From your question is sounds like maybe you have tried this, but just outlining one possible solution from the README in the Python Supported Release release available here.

Note that many Python installations add the current directory to the module search path. If the Python interpreter is invoked from the installer directory, such a configuration will attempt to use the (incomplete) local blpapi directory as a module. If the above import line fails with the message Import Error: No module named _internals, move to a different directory before invoking python.

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

I know this question is a bit stale, but in case people end up here like me. Do you have the C++ version of blpapi? it is a requirement for the python api as mentioned here: https://www.bloomberg.com/professional/support/api-library/

so download the C++ zip installer, extract somewhere, and then add it as an environment variable so that the python api can find it:

Environment variable name: BLPAPI_ROOT Value: C:\blp\blpapi_cpp_3.8.18.1 (THIS IS WHERE MINE IS INSTALLED, YOUR VALUE HERE MAY BE DIFFERENT)

Hope that helps!

Vlox
  • 717
  • 8
  • 18
  • I have this exception, and its finding the C++ sdk and still getting this error unfortunately – Kelvin Oct 29 '18 at 18:38
  • 1
    For those who is looking for answer. I had this problem yesterday. What exactly I did is to download the C++ Supported Release (zip file), then replace the blpapi3_64.dll and blpapi3_32.dll inside C:\blp\DAPI – Louis Ng Oct 06 '20 at 01:28
  • Yes, in retrospect @LouisNg is exactly right... my solution works because if the new DLLs from the C++ blpapi are added to the path and override where python blpapi was looking for the DLL causing issues, it would work. But this answer is much better and cleaner. simply replace the blpapi DLLs with the C++ ones. – Vlox Oct 07 '20 at 13:25