4

I found several questions about the same issue here and here

from pyfinance.ols import PandasRollingOLS

I get the following error:

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'

I tried uninstalling and reinstalling pandas versions 1.1.3, 1.1.2, 1.1.1 and none of them work, I just get the same error, I then tried building pandas in the following fashion:

!python setup.py build_ext --inplace --force

And I still get the same error

2 Answers2

3

Just for reference

I did some digging and it looks like pandas changed their api, which results in the error mentioned. I modified the source code and included the right imports which are in pyfinance/utils.py:

In line 77 changed from:

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

to

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

I created a pull request here if you're facing the same problem, you may clone and install my fork

0

Make sure you have the right version of pyfinance. Installing 0.1.3 solved my issue.

https://pypi.org/project/pyfinance/0.1.3/

ARIF
  • 11
  • 2