jealous / stockstats

Supply a wrapper ``StockDataFrame`` based on the ``pandas.DataFrame`` with inline stock statistics/indicators support.
Other
1.26k stars 297 forks source link

import Error "TypeError: 'type' object is not subscriptable" #179

Open CYLEE21 opened 8 months ago

CYLEE21 commented 8 months ago
from stockstats import wrap

does not work, it shows the following error messages.

     43     pass
     46 _dft_windows = {
     47     # sort alphabetically
     48     'ao': (5, 34),
   (...)
     90     'vwma': 14,
     91 }
---> 94 def set_dft_window(name: str, windows: Union[int, tuple[int, ...]]):
     95     ret = _dft_windows.get(name)
     96     _dft_windows[name] = windows

TypeError: 'type' object is not subscriptable
jealous commented 8 months ago

Please try adding from future import annotations at the beginning of the code.

CYLEE21 commented 8 months ago

It shows the following error

ImportError: cannot import name 'annotations' from 'future'

is future this pacakge? https://pypi.org/project/future/

jealous commented 8 months ago

I think it's a built in package.
https://docs.python.org/3/library/__future__.html

Could you try from __future__ import annotations?

chenqs71 commented 4 months ago

add string ',annotations' at the end of line 27 in stockstats.py

wrx1990 commented 3 months ago

add string ',annotations' at the end of line 27 in stockstats.py在 stockstats.py 中第 27 行末尾添加字符串 ',annotations'

it,worked. image image

code4passion commented 6 days ago

This doesnt work for me

from future import unicode_literals, annotations from stockstats import wrap

Traceback (most recent call last): File "/Users/dshetyo/PycharmProjects/timeseries-predictor/model_trainer.py", line 10, in from data_util import get_data File "/Users/dshetyo/PycharmProjects/timeseries-predictor/data_util.py", line 2, in from stockstats import wrap File "/Users/dshetyo/anaconda3/envs/timeseries/lib/python3.8/site-packages/stockstats.py", line 94, in def set_dft_window(name: str, windows: Union[int, tuple[int, ...]]): TypeError: 'type' object is not subscriptable

CYLEE21 commented 6 days ago

My original problem has been solved by changing the python version. This library has specified the recommened python version. I hope this helps.

jealous commented 5 days ago

What's the python version that has this error?