简体   繁体   中英

blpapi in python version 3.9

I am trying to install the blpapi in python version 3.9

For the record i am able to get 3.7 and 3.8 working using the standard setup and running the pip command at the bottom of this page:

www.bloomberg.com/professional/support/api-library

The only modifications that i needed to make were:

for version 3.7:

py -3.7 -m pip install --index-url=https://bloomberg.bintray.com/pip/simple blpapi

for version 3.8:

py -3.8 -m pip install --index-url=https://bloomberg.bintray.com/pip/simple blpapi

I try exactly the same method for 3.9 but this throws an error:

py -3.9 -m pip install --index-url=https://bloomberg.bintray.com/pip/simple blpapi

This is the error:

Looking in indexes: https://bloomberg.bintray.com/pip/simple
Collecting blpapi
  Downloading https://bloomberg.bintray.com/pip/simple/blpapi/blpapi-3.15.2.tar.gz (229 kB)
     |████████████████████████████████| 229 kB 3.3 MB/s
    ERROR: Command errored out with exit status 1:
     command: 'C:\Python39\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\darren\\AppData\\Local\\Temp\\pip-install-ldwe3a4a\\blpapi\\setup.py'"'"'; __file__='"'"'C:\\Users\\darren\\AppData\\Local\\Temp\\pip-install-ldwe3a4a\\blpapi\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\darren\AppData\Local\Temp\pip-pip-egg-info-ehpqfebq'
         cwd: C:\Users\darren\AppData\Local\Temp\pip-install-ldwe3a4a\blpapi\
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\darren\AppData\Local\Temp\pip-install-ldwe3a4a\blpapi\setup.py", line 54, in <module>
        assert blpapiRoot or (blpapiIncludesVar and blpapiLibVar), \
    AssertionError: BLPAPI_ROOT (or BLPAPI_INCDIR/BLPAPI_LIBDIR) environment variable isn't defined
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

I tried searching for solutions for AssertionError: BLPAPI_ROOT (or BLPAPI_INCDIR/BLPAPI_LIBDIR) environment variable isn't defined but don't find anything that works and at this point am stuck.

Here is my basic code:

import os
import sys
#import xbbg

# check python version
if sys.version_info.major == 3:
    if sys.version_info.minor == 7:
        print('using version: 3.7')
        import blpapi

if sys.version_info.major == 3:
    if sys.version_info.minor == 8:
        print('using version: 3.8')
        with os.add_dll_directory('c:/blp/DAPI'):
            import blpapi


if sys.version_info >= (3,9):
    print('using version: 3.9')
    print('version 3.9 and above not working')
    sys.exit(0) # i added this to exit before the error message for v 3.9
    with os.add_dll_directory('c:/blp/DAPI'):
        import blpapi




x = 'hello world'
print(x)

Can anyone solve this please ?

(ideally having blpapi working with all versions).

According to the blapi documentation, The prebuilt binaries are only available for the the Python versions upto 3.8.

The error is caused because your are forcing the pip to install the blapi binaries for the Python version 3.9 which is not available yet or yet to be released. pip will download and install the latest blapi binaries if the version is not specified.

ie) python -m pip install --index-url=https://bloomberg.bintray.com/pip/simple blpapi

Thank You and Happy Coding :)

Appears as though it is now supported whereas at the time of writing the question it was not:

We support and provide wheels for Python 2.7, 3.6, 3.7, 3.8 and 3.9; Both 32 and 64 bits, for Windows, macOS, and most versions of Linux. These wheels now come bundled with the required C++ API, and a separate C++ API installation is no longer required.

The link is here: https://www.bloomberg.com/professional/support/api-library/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM