Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
CYLEE21 opened this issue Oct 12, 2023 · 8 comments
Open

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

CYLEE21 opened this issue Oct 12, 2023 · 8 comments

Comments

@CYLEE21
Copy link

CYLEE21 commented Oct 12, 2023

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
Copy link
Owner

jealous commented Oct 13, 2023

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

@CYLEE21
Copy link
Author

CYLEE21 commented Oct 13, 2023

It shows the following error

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

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

@jealous
Copy link
Owner

jealous commented Oct 16, 2023

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

Could you try from __future__ import annotations?

@chenqs71
Copy link

chenqs71 commented Mar 7, 2024

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

@wrx1990
Copy link

wrx1990 commented Mar 27, 2024

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

it,worked.
image
image

@code4passion
Copy link

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
Copy link
Author

CYLEE21 commented Jun 30, 2024

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

@CYLEE21 CYLEE21 closed this as completed Jun 30, 2024
@CYLEE21 CYLEE21 reopened this Jun 30, 2024
@jealous
Copy link
Owner

jealous commented Jul 1, 2024

What's the python version that has this error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants