0

I'm getting this error out of nowhere. Has anyone encountered this before?

pandas version = 1.4.2 numpy version = 1.22.3

raise ImportError( ImportError: Unable to import required dependencies: numpy: cannot import name 'ndarray' from partially initialized module 'numpy'

Gunmandu
  • 9
  • 1
  • 1
    What is your code? – Lecdi Apr 30 '22 at 15:21
  • Sounds like you have a circular import in your code somewhere. – John Gordon Apr 30 '22 at 15:27
  • I get the same error just by importing pandas – Gunmandu Apr 30 '22 at 16:00
  • 1
    The classical way to get this type of error is to think "I'm going to play around with numpy, so I'll call my file `numpy.py`!". Then when you try to `import numpy`, your file will import itself and all sorts of confusion follow. If this is not the case, you will have to show us some code that reproduces the issue. – Ture Pålsson Apr 30 '22 at 16:51
  • thank you, everyone! I figured out the reason. I had a file called signal.py. I never thought this would be the name of one of the implementations of pandas/numpy – Gunmandu May 29 '22 at 09:47

1 Answers1

-1

I was randomly getting this error on my MacOS with python3.

When I ran import numpy it was throwing the circular reference error.

To fix it I opened my terminal window and ran:

pip3 install --force --upgrade numpy

Hope this helps!

JayRizzo
  • 3,234
  • 3
  • 33
  • 49