python - AttributeError:模块“数字”没有属性“积分”
问题描述
我在 Mac 上工作。已安装 Python 3.7.0。安装了 Anaconda、Pandas 和 Numpy。
如果我在命令行中输入 Python,在 Python shell 中,我可以输入 import Pandas,它看起来很有效。
但是在科莫多编辑器中,如果我执行:
#!/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
shared by Dušan Maďar
,很可能您有一个名为 ' numbers.py
' 的文件,它可能会干扰 python Lib
。
重命名该文件应该可以解决问题。
推荐阅读
- pycharm - 龟函数在pycharm中不起作用
- java - Azure Java SDK - 同时使用映像创建多个 VM
- tensorflow - 给定一个 Tensoflow MetaGraph,我怎样才能找到这个图的输入张量和输出张量?
- r - R 数小时内无法处理繁重的任务
- xml - 使用 SoapUI 发出请求时面临的问题
- cassandra - 可以直接将 ScyllaDB 2.1.x 升级到 ScyllaDB 3.xx 吗?
- spring-boot - 如何通过弹性搜索找到排序后的数据——spring boot
- python - 错误:引发 portNotOpenError serial.serialutil.SerialException:尝试使用未打开的端口
- symfony - 所有 URL 都转到 web/index.html
- android - 使用底部工作表对话框时,应用程序 MapFragment 锁定为模式