当前位置: 首页 > 面试题库 >

AttributeError:模块“ numbers”没有属性“ Integral”

夏侯瑞
2023-03-14
问题内容

我在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 link共享者Dušan Maďar很可能您有一个名为’numbers.py‘的文件,可能会干扰python Lib

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



 类似资料:
  • 问题内容: 这是我的课: 当我尝试运行该功能时: 我收到以下错误: 我该如何解决? 问题答案: 如果我不得不猜测,您这样做: 在代码的顶部。这意味着您必须执行以下操作: 访问该方法。或者,您可以将import语句更改为此: 并按原样访问它。 制作该模块的人员还命名了他们的班级:

  • 问题内容: 我一直在学习人工智能以及如何使用Python进行编码。我正在从事一个项目,因此我决定更新一些Python软件包,这些软件包并不是新手,然后发生了一些事情并且无法编译我的代码。我删除了Anaconda3并再次设置,但没有用。我一直把这个问题写为主题。如果有人帮助我,我会寻求帮助的。 问题答案: 相同的问题已作为GitHub问题发布。特别地,@allanlavoie建议的解决方案在这里也可

  • 问题内容: import attr >>> @attr.s … class SmartClass(object): … a=attr.ib() … b=attr.ib() … Traceback (most recent call last): File “ “, line 1, in AttributeError: module ‘attr’ has no attribute ‘s’ >>> 我

  • 问题内容: 我已经安装了tensorflow版本r0.11。 在我的文件名中,我已经导入: 并使用它: 尝试在PyCharm中运行我的项目时出现以下错误: 如何解决此错误? 问题答案: 您通常以书面形式汇入, 您可能已经在项目中命名了文件,并且语句正在从该文件导入。 另外,您也可以尝试一下

  • 我已经在我的Ubuntu机器上安装了TensorFlow版本1.14.0。我正在尝试使用运行代码 我得到一个错误 完全回溯 Traceback(最近一次调用): File",第1行,在 File"/home/amitbhanja/python-环境/env/lib/python3.6/site-包/keras/init.py",第3行,在 from. index utils File"/home/

  • 我试图将keras.initializers引入我的网络,以下链接: 并且它失败,出现以下错误: 你知道为什么会这样吗?