Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: 'numpy._DTypeMeta' object is not subscriptable

I'm trying to type hint a numpy ndarray like this:

RGB = numpy.dtype[numpy.uint8]
ThreeD = tuple[int, int, int]

def load_images(paths: list[str]) -> tuple[list[numpy.ndarray[ThreeD, RGB]], list[str]]: ...

but at the first line when I run this, I got the following error:

RGB = numpy.dtype[numpy.uint8]
TypeError: 'numpy._DTypeMeta' object is not subscriptable

How do I type hint a ndarray correctly?

like image 433
palapapa Avatar asked Mar 06 '26 19:03

palapapa


1 Answers

I had a similar issue with my opencv2 library, which I by upgrading numpy pip install numpy --upgrade

like image 100
Prannav Prasad Lalath Avatar answered Mar 09 '26 07:03

Prannav Prasad Lalath