导入tia库以从彭博社提取数据时出现错误消息

2024-05-17 00:13:08 发布

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

我正试图使用tia库将彭博数据直接提取到一个数据框中,一直遵循这个思路 How do I store data from the Bloomberg API into a Pandas dataframe?

现在,当我尝试使用下面的命令导入tia时 import tia.bbg.datamgr as dm

我得到这个错误消息

Traceback (most recent call last):
  File "/Users/prasadkamath/anaconda2/envs/Pk/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3319, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-17-7422282d1b65>", line 1, in <module>
    import tia.bbg.datamgr as dm
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/Users/prasadkamath/anaconda2/envs/Pk/lib/python3.6/site-packages/tia/bbg/__init__.py", line 1, in <module>
    from tia.bbg.v3api import *
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/Users/prasadkamath/anaconda2/envs/Pk/lib/python3.6/site-packages/tia/bbg/v3api.py", line 186
    print 'unhandled event: %s' % evt.EventType
                              ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('unhandled event: %s' % evt.EventType)?

有人知道我该怎么解决这个问题吗

谢谢


Tags: inpyimportselflinedousersfile
1条回答
网友
1楼 · 发布于 2024-05-17 00:13:08

您正在使用Python 3。目前,TIA仅与Python 2兼容

您看到的错误是因为在TIA文件中,print没有括号,这是Python 2风格的

这里https://github.com/bpsmith/tia/issues/11有一个Python 3转换。我最近一直在用这个,它非常好

相关问题 更多 >