When importing sklearn datasets eg.
JavaScript
x
3
1
from sklearn.datasets import fetch_mldata
2
from sklearn.datasets import fetch_openml
3
I get the error
JavaScript
1
28
28
1
Traceback (most recent call last):
2
File "numbers.py", line 1, in <module>
3
from sklearn.datasets import fetch_openml
4
File "/anaconda2/envs/numbers/lib/python3.5/site-packages/sklearn/__init__.py", line 64, in <module>
5
from .base import clone
6
File "/anaconda2/envs/numbers/lib/python3.5/site-packages/sklearn/base.py", line 11, in <module>
7
import numpy as np
8
File "/anaconda2/envs/numbers/lib/python3.5/site-packages/numpy/__init__.py", line 142, in <module>
9
from . import core
10
File "/anaconda2/envs/numbers/lib/python3.5/site-packages/numpy/core/__init__.py", line 93, in <module>
11
from . import numerictypes as nt
12
File "/anaconda2/envs/numbers/lib/python3.5/site-packages/numpy/core/numerictypes.py", line 86, in <module>
13
import numbers
14
File "/Users/airocoop/repos/Numbers/numbers.py", line 1, in <module>
15
from sklearn.datasets import fetch_openml
16
File "/anaconda2/envs/numbers/lib/python3.5/site-packages/sklearn/datasets/__init__.py", line 6, in <module>
17
from .base import load_breast_cancer
18
File "/anaconda2/envs/numbers/lib/python3.5/site-packages/sklearn/datasets/base.py", line 20, in <module>
19
from ..utils import Bunch
20
File "/anaconda2/envs/numbers/lib/python3.5/site-packages/sklearn/utils/__init__.py", line 10, in <module>
21
from scipy.sparse import issparse
22
File "/anaconda2/envs/numbers/lib/python3.5/site-packages/scipy/__init__.py", line 72, in <module>
23
from numpy.random import rand, randn
24
File "/anaconda2/envs/numbers/lib/python3.5/site-packages/numpy/random/__init__.py", line 143, in <module>
25
from .mtrand import *
26
File "numpy.pxd", line 87, in init mtrand
27
AttributeError: module 'numpy' has no attribute 'dtype'
28
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. Any help on this issue would be greatly appreciated
Advertisement
Answer
I figured this out. The answer is that the file I was running was named 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
Easy way to check is move the file with the import statement to a different directory and try running it.