0

I want to use the array method from the numpy package, but I get an attribute error and it says that there is no method called array. what is the problem?

import numpy as np

x = [2, 3, 4, 6, 7, 9]
y = np.array(x)
print(y)

AttributeError: partially initialized module 'numpy' has no attribute 'array' (most likely due to a circular import)

2
  • it is not importing numpy correctly probably because you have a file named numpy.py Commented Aug 25, 2022 at 6:45
  • Yes, you mentioned the right point. Thank you Commented Aug 25, 2022 at 6:52

1 Answer 1

1

A way to debug this behaviour is to print the origin of the file that you are importing:

import numpy as np
print(np.__file__)

This will return the path of your imported package and you could realise that it is not the one you intended to import.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.