我正在尝试在 Spyder 中使用 sklearn。一开始我尝试导入它时遇到ImportError: No module named sklearn
然后我绑定到使用 PYTHONPATH 管理器设置 PATH,然后使用工具菜单中的“更新模块名称列表”。然后重新启动 spydet 但没有成功。
最后我将 sklearn 文件夹复制到/Applications/Spyder.app/Contents/Resources/lib/python2.7
这就是我找到 sklearn 的 PATH 并将其复制到此文件夹中的方式:
>>> import sklearn
>>> sklearn
<module 'sklearn' from '/Library/Python/2.7/site-packages/scikit_learn-0.12_git-py2.7-macosx-10.7-intel.egg/sklearn/__init__.pyc'>
>>>
然后我 cd 到父文件夹:
cp -r sklearn /Applications/Spyder.app/Contents/Resources/lib/python2.7
但是当我尝试将 sklearn 导入到 spyder 时,例如sklearn import dataset
:
Traceback (most recent call last):
File "/Users/mohsenjadidi/Documents/workspace/dsv/test.py", line 10, in <module>
from sklearn import dataset
File "/Applications/Spyder.app/Contents/Resources/lib/python2.7/sklearn/__init__.py", line 17, in <module>
from .base import clone
File "/Applications/Spyder.app/Contents/Resources/lib/python2.7/sklearn/base.py", line 11, in <module>
from .metrics import r2_score
File "/Applications/Spyder.app/Contents/Resources/lib/python2.7/sklearn/metrics/__init__.py", line 6, in <module>
from .metrics import confusion_matrix, roc_curve, auc, precision_score, \
File "/Applications/Spyder.app/Contents/Resources/lib/python2.7/sklearn/metrics/metrics.py", line 17, in <module>
from ..utils import check_arrays
File "/Applications/Spyder.app/Contents/Resources/lib/python2.7/sklearn/utils/__init__.py", line 9, in <module>
from .murmurhash import murmurhash3_32
File "numpy.pxd", line 151, in init sklearn.utils.murmurhash (sklearn/utils/murmurhash.c:4773)
ValueError: numpy.dtype has the wrong size, try recompiling
有什么想法吗?谢谢