以下代码正确运行,直到我在numpy软件包https://github.com/numpy/numpy/blob/master/numpy/core/fromnumeric.py#L19中向该行添加了from joblib import Parallel, delayed
。有人知道如何解决吗?我想在numpy包中使用joblib库。谢谢!
from sklearn import preprocessing
import numpy as np
X_train = np.random.randn(4, 4)
print(X_train)
X_scaled = preprocessing.scale(X_train)
错误消息如下:
File "sklearn_scale_test.py", line 1, in <module>
from sklearn import preprocessing
File "/usr/local/lib/python3.6/site-packages/sklearn/__init__.py", line 76, in <module>
from .base import clone
File "/usr/local/lib/python3.6/site-packages/sklearn/base.py", line 13, in <module>
import numpy as np
File "/usr/local/lib/python3.6/site-packages/numpy/__init__.py", line 142, in <module>
from . import core
File "/usr/local/lib/python3.6/site-packages/numpy/core/__init__.py", line 95, in <module>
from . import numeric
File "/usr/local/lib/python3.6/site-packages/numpy/core/numeric.py", line 3093, in <module>
from . import fromnumeric
File "/usr/local/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 18, in <module>
from joblib import Parallel, delayed
File "/usr/local/lib/python3.6/site-packages/joblib/__init__.py", line 119, in <module>
from .parallel import Parallel
File "/usr/local/lib/python3.6/site-packages/joblib/parallel.py", line 28, in <module>
from ._parallel_backends import (FallbackToBackend, MultiprocessingBackend,
File "/usr/local/lib/python3.6/site-packages/joblib/_parallel_backends.py", line 20, in <module>
from .pool import MemmappingPool
File "/usr/local/lib/python3.6/site-packages/joblib/pool.py", line 33, in <module>
from ._memmapping_reducer import get_memmapping_reducers
File "/usr/local/lib/python3.6/site-packages/joblib/_memmapping_reducer.py", line 37, in <module>
from numpy.lib.stride_tricks import as_strided
File "/usr/local/lib/python3.6/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python3.6/site-packages/numpy/lib/type_check.py", line 13, in <module>
import numpy.core.numeric as _nx
AttributeError: module 'numpy' has no attribute 'core'