Search code examples
python-3.xnumpypycharm

pycharm Unresolved attribute reference 'astype' for class 'ndarray'


enter image description here

Q: How can I fix the bug where Pychram warns about numpy.ndarray attributes?

The code runs with no problem, however PyCharm keeps giving this warning:

Unresolved attribute reference 'astype' for class 'ndarray'

It's not only this, but other methods such as .tolist(), and np.sum().

I am using Python 3.9.7

PyCharm has been behaving very weirdly when it comes to numpy related code. any clues?


Solution

  • I was seeing this problem today, and it wasn't fixed by restarting or invalidating Pycharm's caches. It did go away after updating Pycharm to the latest version (2024.1.5) however.