【发布时间】:2020-11-06 19:31:55
【问题描述】:
当我尝试使用 numpy 时,出现错误,如下所示。我有 2 个问题,我如何使用 numpy,我使用 pip 安装,以及我如何理解错误消息。我是python的新手
import numpy as np
array_a = np.array([1, 2, 3, 4, 5])
print(array_a)
错误:
[Johnnys-MBP:~/Desktop/python] johnbarrett% /usr/local/bin/python3 /Users/johnbarrett/Desktop/python/data.py
<class 'complex'>
1.4
2
Traceback (most recent call last):
File "/Users/johnbarrett/Desktop/python/data.py", line 1, in <module>
import numpy as np
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/__init__.py", line 140, in <module>
from . import core
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/__init__.py", line 70, in <module>
from . import numerictypes as nt
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/numerictypes.py", line 566, in <module>
_register_types()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/numerictypes.py", line 561, in _register_types
numbers.Integral.register(integer)
AttributeError: module 'numbers' has no attribute 'Integral'
【问题讨论】:
-
看起来这个问题已经回答了here。