from pyfinance.ols import PandasRollingOLS
我收到以下错误:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/pyfinance/utils.py", line 78, in <module>
from pandas.tseries.frequencies import FreqGroup, get_freq_code
ImportError: cannot import name 'FreqGroup' from 'pandas.tseries.frequencies' (/usr/local/lib/python3.8/site-packages/pandas/tseries/frequencies.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.8/site-packages/pyfinance/__init__.py", line 32, in <module>
from .returns import TFrame, TSeries # noqa
File "/usr/local/lib/python3.8/site-packages/pyfinance/returns.py", line 42, in <module>
from pyfinance import ols, utils
File "/usr/local/lib/python3.8/site-packages/pyfinance/ols.py", line 15, in <module>
from pyfinance import utils
File "/usr/local/lib/python3.8/site-packages/pyfinance/utils.py", line 80, in <module>
from pandas._libs.tslibs.frequencies import FreqGroup, get_freq_code
ModuleNotFoundError: No module named 'pandas._libs.tslibs.frequencies'
我尝试卸载并重新安装pandas版本1.1.3、1.1.2、1.1.1,但它们均无法正常工作,我只是遇到了相同的错误,然后尝试以以下方式构建pandas:
!python setup.py build_ext --inplace --force
我仍然遇到相同的错误
答案 0 :(得分:1)
仅供参考
我做了一些挖掘,看起来熊猫更改了它们的api,这导致了所提到的错误。我修改了源代码,并在pyfinance/utils.py
中包含了正确的导入:
第77行的内容从:
try:
from pandas.tseries.frequencies import FreqGroup, get_freq_code
except ImportError: # 0.24+, or somewhere around then
from pandas._libs.tslibs.frequencies import FreqGroup, get_freq_code
到
try:
from pandas.tseries.frequencies import FreqGroup, get_freq_code
except ImportError:
from pandas._libs.tslibs.dtypes import FreqGroup
from pandas.tests.tslibs.test_period_asfreq import get_freq_code
答案 1 :(得分:0)
确保您拥有正确版本的 pyfinance。安装 0.1.3 解决了我的问题。