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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With