Anaconda使用bloomberg API的No module named ‘blpapi‘報錯解決
阿新 • • 發佈:2021-02-01
1. 問題背景
用python在使用bloomberg API的時候,出現瞭如下報錯
>>> import pdblp Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\scum\anaconda3\lib\site-packages\pdblp\__init__.py", line 1, in <module> from .pdblp import BCon # NOQA File "C:\Users\scum\anaconda3\lib\site-packages\pdblp\pdblp.py", line 4, in <module> import blpapi ModuleNotFoundError: No module named 'blpapi'
2. 嘗試解決方案
根據報錯嘗試安裝‘blpapi’,但全部失敗
pip install blpapi
pip3 install blpapi
conda install blpapi
3. 成功解決方案
用anaconda search blpapi尋找‘blpapi’包
$ anaconda search blpapi Using Anaconda API: https://api.anaconda.org Packages: Name | Version | Package Types | Platforms | Builds ------------------------- | ------ | --------------- | --------------- | ---------- conda-forge/blpapi | 3.15.2 | conda | linux-64, win-64, osx-64 | py36_blpapicpp3.8.18.1_1, py27h2d50403_0, py27_blpapicpp3.8.18.1_1, py36_blpapicpp3.12.2.1_0, py36_blpapicpp3.12.2.1_1, py27_blpapicpp3.12.3.1_0, py37_blpapicpp3.14.3.1_0, py27_blpapicpp3.12.2.1_1001, py36_blpapicpp3.14.3.1_1, py36_blpapicpp3.14.3.1_0, py37_blpapicpp3.14.3.1_1, py27_blpapicpp3.14.3.1_0, py37_blpapicpp3.15.0.1_0, py37_blpapicpp3.12.2.1_1, py38_blpapicpp3.14.3.1_0, py37_blpapicpp3.12.2.1_1001, py36_blpapicpp3.12.3.1_0, py27_blpapicpp3.13.1.1_0, py36he980bc4_0, py37_blpapicpp3.12.3.1_0, py36_blpapicpp3.13.1.1_0, py38_blpapicpp3.13.1.1_0, py38_blpapicpp3.14.3.1_1, py36_blpapicpp3.12.2.1_1001, py38_blpapicpp3.15.0.1_0, py27_blpapicpp3.12.2.1_0, py27_blpapicpp3.12.2.1_1, py36_blpapicpp3.8.1.1_1, py37_blpapicpp3.13.1.1_0, py36_blpapicpp3.15.0.1_0, py27hdc96acc_0, py36h2d50403_0, py27_blpapicpp3.8.1.1_1 : Python SDK for Bloomberg BLPAPI (<=3.9) dsm/blpapi | 3.9.0 | conda | linux-64, win-64 | py36_0, py27_0 josh/blpapi | 3.5.5 | conda | linux-64 | py27_0 macinv/blpapi | 3.9.0 | conda | linux-64, win-64 | py36_0, py34_0, py35_0, py27_0 mbonix/blpapi | 3.9.0 | conda | win-64 | py36_0 : Bloomberg's Open Market Data Initiative is part of the company's ongoing effort to foster open solutions for the financial services industry. r_test/r-rblpapi | 0.3.10 | conda | linux-64, win-64 | r36h796a38f_0, r36h29659fb_0 : An R Interface to 'Bloomberg' is provided via the 'Blp API'. Found 6 packages Run 'anaconda show <USER/PACKAGE>' to get installation details
根據最後一行的提示搜尋所需要的包
$ anaconda show conda-forge/blpapi Using Anaconda API: https://api.anaconda.org Name: blpapi Summary: Python SDK for Bloomberg BLPAPI (<=3.9) Access: public Package Types: conda Versions: + 3.9.2 + 3.12.2 + 3.13.1 + 3.14.0 + 3.15.2 To install this package with conda run: conda install --channel https://conda.anaconda.org/conda-forge blpapi
根據最後一行的提示安裝
$ conda install --channel https://conda.anaconda.org/conda-forge blpapi
最後成功解決
>>> import pdblp
>>>