Python 2.7 with blomberg api blpapi api error

This is my development environment:

  • Windows 7 on an HP Pavilion 64-bit laptop.
  • Python 2.7, 32-bit in folder C: \ python27
  • The development environment is Eclipse with PyDev, but that doesn't seem to matter, because I get the same failure if I use Anaconda or Notepad ++.
  • Python 2.7 Binary Installer for Windows - 32-bit v3.5.3 After installing the PATH environment on Windows for Python, BLPAPI finds and installs in C: \ Python27, creating C:\Python27\Lib\site-packages\blpapi .

Earlier in my 32-bit installation of Python and BLPAPI, I tried 64-bit Python 2.7 with a 64-bit installation of BLPAPI, but the results are the same for 64-bit or 32-bit.

My Python script does not work on this line: import blpapi

PyDev generates this error code:

 Traceback (most recent call last): File "C:\Users\Greg\workspace2\Bloomberg\src\TestImport.py", line 1, in <module> import blpapi File "C:\Python27\lib\site-packages\blpapi\__init__.py", line 5, in <module> from .internals import CorrelationId File "C:\Python27\lib\site-packages\blpapi\internals.py", line 50, in <module> _internals = swig_import_helper() File "C:\Python27\lib\site-packages\blpapi\internals.py", line 46, in swig_import_helper _mod = imp.load_module('_internals', fp, pathname, description) ImportError: DLL load failed: The specified module could not be found. 
+6
source share
3 answers

I ran into a similar problem and spent some time fixing the problem using Bloomberg Support. Here is what I learned:

ImportError is a result of the fact that Bloomberg cannot find the dll file blpapi3_32.dll. This DLL file can be located in the \ bin or \ lib folder of the Bloomberg C / C ++ library, which is located in the same place where you received the Python executable. So download this library (v3.7.5.1 at the time of this writing), and your environment variable "Path" includes this location. This should solve the problem.

PS you can access the PATH variable using the menu "Start"> "Computer"> "Properties"> "Advanced system settings"> "Advanced" (tab)> "Environment variables"> find the variable "Path" in the "System" variables. " Change this variable to indicate the location of the DLL file, for example. if the original Path variable is "C: \ Python27 \ Lib \ site-packages \ PyQt4", then the new Path variable should be "C: \ Python27 \ Lib \ site-packages \ PyQt4; C: \ blp \ API \ blpapi_cpp_3. 7.5 .1 \ Bin "

+11
source

Check out this article from Bloomberg:

In order for python scripts to call Bloomberg API functions, libraries distributed as part of the Bloomberg C ++ SDK must be available to the Python interpreter. Installation step 3 above provides a system-wide installation of this library. Linux / Solaris / * Nicks users without system-wide installations must set LD_LIBRARY_PATH (or DYLD_LIBRARY_PATH on Darwin / MacOS X) for an environment variable including a directory containing blpapi3 shared libraries. Windows users may need to set the PATH variable to a directory containing blpapi3_32.dll or blpapi3_64.dll. (Note that Windows users with the Bloomberg Terminal Installed Software already have versions of these libraries in their PATH.)

So what I did (very similar to Ken She's answer):

  • Download C / C ++ lib for Windows

  • Extract files from blpapi_cpp_3.8.8.1.zip (or similar)

  • Copy the blpapi3_32.dll file from the bin folder and paste it into a safe place

In my case, I pasted it into the folder C: \ Python27 \ Lib \ site-packages \ blpapi

  1. Add this route to the Path environment variable

    • Click Start / right-click Computer / Properties / Advanced System Settings / Advanced Tab / Environment Variables

    • Double-click "Path" in the "System Variables" list

    • Add a semicolon (;) and your path as shown below

For me: C: \ Python27 \ Lib \ site-packages \ blpapi

enter image description here

Now this should work for you. Hope this helps.

+6
source

I had the same problem that was just resolved after updating the Bloomberg terminal application.

0
source

Source: https://habr.com/ru/post/971080/


All Articles