Getting "RuntimeError: Numpy is not available" whenever trying with "torch.from_numpy"

When I try to run a simple code, I receive an error saying that Numpy is not available.

import torch
import numpy as np
data = np.array([1, 2, 3], dtype=np.uint8)
tensor = torch.from_numpy(data)

Traceback (most recent call last): File “E:\test.py”, line 74, in
tensor = torch.from_numpy(data)
E:\test.py:74: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at …\torch\csrc\utils\tensor_numpy.cpp:84.)
tensor = torch.from_numpy(data)
Traceback (most recent call last):
File “E:\test.py”, line 74, in
tensor = torch.from_numpy(data)
^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Numpy is not available

Currently i am using
python : 3.11
torch : 2.3.1
numpy : 2.0.1

why is this error happening in PyTorch? When i am using the same version of pytorch with the older version numpy(1.26.4) i am not getting any errors.

I guess numpy>=2 might not be supported in your PyTorch build yet. You might want to update to torch==2.4.0 or a nightly release as it seems Linux binaries work while Windows has issues according to this issue.