Skip to content
Advertisement

import attrmap gives TypeError: ‘type’ object is not subscriptable

I’m trying to use the library AttrMap which is suggested as an alternative to AttrDict library. From the documentation of AttrDict:

… If either of these caveats are deal-breakers, or you don’t need your object to be a dict, consider using AttrMap instead.

I installed it with pip install attrmap and imported it in a fresh conda environment, as usual with import attrmap.

However the import gives the following error:

JavaScript

I’ve already tried installing different previous versions and adding the import in a Colab notebook, all with same error.

Does anyone knows what the issue might be? I don’t think is related to my environment.

Advertisement

Answer

list[str] is a type annotation available since python 3.9, the traceback shows your system uses python 3.8, try upgrading your python or downgrading attrmap.

It might be worth reporting this issue to the attrmap developer.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement