Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A question about "ModuleNotFoundError: No module named 'numpy.typing'"

I am trying to import ArrayLike doing from numpy.typing import ArrayLike, and I get the error mentioned in the title:

ModuleNotFoundError: No module named 'numpy.typing'

I know I could simply write import numpy.typing as npt as the documentation shows, but I would like the simplicity of just importing the types that I want to use. It is also not the first time that this has happened to me: I want to import a specific method/class but I'm forced to import the parent module with a nickname instead because otherwise, I get an Error. Why's that?

like image 621
condosz Avatar asked Apr 16 '21 01:04

condosz


1 Answers

Re-posting the resolution in the comments above as a community wiki for better visibility:

The numpy typing module was introduced in numpy 1.20

Make sure that you have the correct numpy version by running the following at the beginning of your notebook:

%pip install -U numpy
like image 132
Rayan Hatout Avatar answered Sep 16 '22 15:09

Rayan Hatout