Numpy y pandas problem import

When I try to import numpy and pandas I get this error

Traceback (most recent call last):
File “C:\Users\XXX\Documents\Python\numpy.py”, line 1, in
import numpy
File “C:\Users\XXX\Documents\Python\numpy.py”, line 2, in
import pandas
File “C:\Users\XXX\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas_init_.py”, line 22, in
from pandas.compat import is_numpy_dev as is_numpy_dev
File "C:\UsersXXX\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\compat_init
.py", line 13, in
from pandas._typing import F
File “C:\Users\XXX\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas_typing.py”, line 78, in
ArrayLike = Union[“ExtensionArray”, np.ndarray]
AttributeError: partially initialized module ‘numpy’ has no attribute ‘ndarray’ (most likely due to a circular import)

Hi Barry,

sooner or later most people new to Python make this mistake: don’t call your script numpy.py - what you’re seeing here is Python importing your numpy.py when you write import numpy, rather than the “real” numpy.

2 Likes

Thanks, changed name of file testing numpy and pandas and now it works.