[英]module 'numpy' has no attribute 'dtype'
When importing sklearn datasets eg. 导入sklearn数据集时,例如
from sklearn.datasets import fetch_mldata
from sklearn.datasets import fetch_openml
I get the error 我得到错误
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'
I am not sure why I get this 我不确定为什么会得到这个
I don't get this error when running things from a jupyter notebook, which is also weird. 从jupyter笔记本上运行东西时,我也没有收到此错误,这也很奇怪。 Any help on this issue would be greatly appreciated
在这个问题上的任何帮助将不胜感激
I figured this out. 我想通了。 The answer is that the file I was running was named numbers.py.
答案是我正在运行的文件名为numbers.py。 This screws the whole thing up.
这把整个事情搞砸了。 If you have this problem check to make sure you don't have a file in the directory called numbers.py
如果遇到此问题,请检查以确保目录中没有文件numbers.py。
Easy way to check is move the file with the import statement to a different directory and try running it. 简单的检查方法是将带有import语句的文件移动到另一个目录,然后尝试运行它。
Broken installation. 安装损坏。
Do this: 做这个:
1) 1)
conda install numpy=1.13
or 2) 或2)
pip install numpy --upgrade
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.