How to solve this error in VS Code - AttributeError partially initialized module main has no attribute array most likely due to a circular import

0 votes

code

import numpy as np

#we can create a numpy array from a list

python_list = [1, 2, 3, 4]

numpy_array = np.array(python_list)

print(numpy_array)

output:

PS C:\Users\lenovo\Documents\PYTHON 2> python -u "c:\Users\lenovo\Documents\PYTHON 2\main.py"
Traceback (most recent call last):
  File "c:\Users\lenovo\Documents\PYTHON 2\main.py", line 1, in <module>
    import main as np
  File "c:\Users\lenovo\Documents\PYTHON 2\main.py", line 6, in <module>
    numpy_array = np.array(python_list)
AttributeError: partially initialized module 'main' has no attribute 'array' (most likely due to a circular import)

Jul 11, 2022 in Python by PRACHI

edited Mar 4, 2025 692 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP