python - 属性错误 : module 'numbers' has no attribute 'Integral'

标签 python python-3.x pandas

我在 Mac 上工作。 已安装 Python 3.7.0。安装了 Anaconda、Pandas 和 Numpy。

在命令行中,如果我输入 Python,在 Python shell 中,我可以输入 import Pandas,它看起来很有效。

但是在 Komodo Editor 中,如果我执行:

#!/usr/bin/env python3

import pandas

我收到以下错误:

AttributeError: module 'numbers' has no attribute 'Integral'

编辑:

完整代码如下:

#!/usr/bin/env python3

import pandas

def main():
    print('Hello, World.')

if __name__ == '__main__': main()

这是回溯:

Traceback (most recent call last):
  File "/Users/Barry/Documents/Python/testpanda.py", line 3, in <module>
    import pandas
  File "/usr/local/lib/python3.7/site-packages/pandas/__init__.py", line 13, in <module>
    __import__(dependency)
  File "/usr/local/lib/python3.7/site-packages/numpy/__init__.py", line 142, in <module>
    from . import add_newdocs
  File "/usr/local/lib/python3.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/usr/local/lib/python3.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
    from .type_check import *
  File "/usr/local/lib/python3.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "/usr/local/lib/python3.7/site-packages/numpy/core/__init__.py", line 35, in <module>
    from . import _internal  # for freeze programs
  File "/usr/local/lib/python3.7/site-packages/numpy/core/_internal.py", line 18, in <module>
    from .numerictypes import object_
  File "/usr/local/lib/python3.7/site-packages/numpy/core/numerictypes.py", line 948, in <module>
    _register_types()
  File "/usr/local/lib/python3.7/site-packages/numpy/core/numerictypes.py", line 943, in _register_types
    numbers.Integral.register(integer)
AttributeError: module 'numbers' has no attribute 'Integral'

最佳答案

查看 github linkDušan Maďar 共享,很可能您有一个名为“numbers.py”的文件,它可能会干扰 python Lib.

重命名该文件应该可以解决问题。

关于python - 属性错误 : module 'numbers' has no attribute 'Integral' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53668779/

相关文章:

python - Pandas:根据字典中存在的值保留列值,并将其他列设为空白

python - 对两个列表使用 max 函数有什么意义?

python - 为多个根目录调用 os.walk?

python list to dict转换困惑

Python:如何在操作系统中打开文件时写入文件

Python 3 正则表达式问题

python - 使用 pandas 将日期列转换为标准格式

python - 无法检查数组内的任何项目是否也在另一个数据框中

python - 在 Python 上将 .EDF 文件转换为 .txt

Python队列模块难度