AttributeError: 'module' object has no attribute 'TimeSeries' after python Validation.py

3.4k Views Asked by At

Just starting Computational Investing by Tucker Balch. I'm using virtualbox and installed Ubuntu. After installing QSTK, I ran python Validation.py (Step 7). I keep getting an:

AttributeError: 'module' object has no attribute 'TimeSeries'

There are many similar questions so I believe problem is the use of the same name as the file somewhere in the code. I was wondering if anyone had a solution specific to this class and QSTK.

The full error is:

Traceback (most recent call last):
 File "Validation.py", line 122 in <module>
  import QSTK.qstkutil.tsutil as tsu
 File "usr/local/lib/python2.7/dist-packages/QSTK-0.2.8 py2.7.egg/QSTK/qstkutil/tsutil.py", line 19, in <module>
  from QSTK.qstkutil import qsdateutil
 File "usr/local/lib/python2.7/dist-packages/QSTK-0.2.8-py2.7.egg/QSTK/qstkutil/qsdateutil.py", line 38, in <module>
  GTS_DATES = _cache_dates()
 File "usr/local/lib/python2.7/dist-packages/QSTK-0.2.8-py2.7.egg/QSTK/qstkutil/qsdateutil.py", line 36, in _cache_dates
  return pd.TimeSeries(index=dates, data=dates) 
AttributeError: 'module' object has no attribute 'TimeSeries' 
3

There are 3 best solutions below

1
On

Corley is spot on. You can solve the problem by changing 2 occurrences of "TimeSeries" to "Series" in /usr/local/lib/python2.7/dist-packages/QSTK-0.2.8-py2.7.egg/QSTK/qstkutil/qsdateutil.py. "TimeSeries" also appears once in /usr/local/lib/python2.7/dist-packages/QSTK-0.2.8-py2.7.egg/QSTK/qstkutil/tsutil.py but I haven't encountered an error yet due to it.

0
On

Changing TimeSeries to Series corrects the issue for me.

Seems that

import pandas as pd; 
pd.TimeSeries = pd.Series        

should work, but did not for me.

0
On

I encountered this issue too. This caused by the pandas lib. You can get into the path(my file path is /Library/Python/2.7/site-packages/QSTK/qstkutil) where the qstkutil.py of QSTK located. Then change all the 'TimeSeries' of this file as 'Series'.

You can also get some insights from here(https://github.com/QuantSoftware/QuantSoftwareToolkit/issues/73)