简体   繁体   中英

Using the array method from the numpy package in Python

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)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM