python版本3.9中的blpapi

2024-04-19 12:59:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试在python版本3.9中安装blpapi

作为记录,我能够使用标准设置并运行本页底部的pip命令使3.7和3.8正常工作:

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

我需要做的唯一修改是:

对于3.7版:

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

对于3.8版:

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

我对3.9尝试了完全相同的方法,但这会引发一个错误:

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

这就是错误:

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.

我试图为AssertionError: BLPAPI_ROOT (or BLPAPI_INCDIR/BLPAPI_LIBDIR) environment variable isn't defined寻找解决方案,但没有找到任何有效的方法,此时我陷入了困境

这是我的基本代码:

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)

谁能解决这个问题

(理想情况下,blpapi使用所有版本)


Tags: installpippyhttpsimportinfocomversion
2条回答

似乎现在支持它,而在撰写问题时,它不是:

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.

链接如下: https://www.bloomberg.com/professional/support/api-library/

根据blapi文档,预构建的二进制文件仅适用于高达3.8的Python版本

导致此错误的原因是,您正在强制pip安装Python版本3.9的blapi binaries,该版本尚未提供或尚未发布。pip将下载并安装最新的blapi binaries,如果未指定版本

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

谢谢你,快乐编码:)

相关问题 更多 >