模块“ numpy”没有属性“ dtype”

时间:2019-03-11 19:19:01

标签: python numpy scikit-learn python-3.5 python-import

导入sklearn数据集时,例如

from sklearn.datasets import fetch_mldata
from sklearn.datasets import fetch_openml

我得到了错误

Traceback (most recent call last):
  File "numbers.py", line 1, in <module>
    from sklearn.datasets import fetch_openml
  File "/anaconda2/envs/numbers/lib/python3.5/site-packages/sklearn/__init__.py", line 64, in <module>
    from .base import clone
  File "/anaconda2/envs/numbers/lib/python3.5/site-packages/sklearn/base.py", line 11, in <module>
    import numpy as np
  File "/anaconda2/envs/numbers/lib/python3.5/site-packages/numpy/__init__.py", line 142, in <module>
    from . import core
  File "/anaconda2/envs/numbers/lib/python3.5/site-packages/numpy/core/__init__.py", line 93, in <module>
    from . import numerictypes as nt
  File "/anaconda2/envs/numbers/lib/python3.5/site-packages/numpy/core/numerictypes.py", line 86, in <module>
    import numbers
  File "/Users/airocoop/repos/Numbers/numbers.py", line 1, in <module>
    from sklearn.datasets import fetch_openml
  File "/anaconda2/envs/numbers/lib/python3.5/site-packages/sklearn/datasets/__init__.py", line 6, in <module>
    from .base import load_breast_cancer
  File "/anaconda2/envs/numbers/lib/python3.5/site-packages/sklearn/datasets/base.py", line 20, in <module>
    from ..utils import Bunch
  File "/anaconda2/envs/numbers/lib/python3.5/site-packages/sklearn/utils/__init__.py", line 10, in <module>
    from scipy.sparse import issparse
  File "/anaconda2/envs/numbers/lib/python3.5/site-packages/scipy/__init__.py", line 72, in <module>
    from numpy.random import rand, randn
  File "/anaconda2/envs/numbers/lib/python3.5/site-packages/numpy/random/__init__.py", line 143, in <module>
    from .mtrand import *
  File "numpy.pxd", line 87, in init mtrand
AttributeError: module 'numpy' has no attribute 'dtype'

我不确定为什么会得到这个

从jupyter笔记本上运行东西时,我也没有收到此错误,这也很奇怪。在这个问题上的任何帮助将不胜感激

2 个答案:

答案 0 :(得分:0)

安装中断。

执行以下操作:

1)

@Query("SELECT * FROM  progressTask_table UNION SELECT * FROM todolistTask_table")
LiveData<List<Task>> getAllTasks();

或2)

conda install numpy=1.13

答案 1 :(得分:0)

我知道了。答案是我正在运行的文件名为numbers.py。这把整个事情搞砸了。如果您遇到此问题,请检查以确保目录中没有文件numbers.py

一种简便的检查方法是将带有import语句的文件移动到另一个目录,然后尝试运行它。