本文介绍了在执行教程时使用sklearn遇到ImportError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试遵循sklearn提供的机器学习101教程,但我一直遇到错误.

Hi I'm trying to follow the machine learning 101 tutorial provided by sklearn, and I keep running into an error.

我从这里下载的sklearn版本最多: https://github.com/scikit -learn/scikit-learn

I have the most the sklearn version downloaded from here: https://github.com/scikit-learn/scikit-learn

我运行Windows

I run Windows

python:2.7.5(32位)

python: 2.7.5 (32bit)

scipy:.12

scipy: .12

numpy:1.7.0

numpy: 1.7.0

我跑步时

from sklearn.linear_model import LinearRegression
model = LinearRegression()

我知道

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-7-9f5ae92552bb> in <module>()
----> 1 from sklearn.linear_model import LinearRegression
      2 model = LinearRegression()

C:\WinPython-32bit-2.7.5.1\python-2.7.5\lib\site-packages\sklearn\linear_model\__init__.py in <module>()
     10 # complete documentation.
     11 
---> 12 from .base import LinearRegression
     13 
     14 from .bayes import BayesianRidge, ARDRegression

C:\WinPython-32bit-2.7.5.1\python-2.7.5\lib\site-packages\sklearn\linear_model\base.py in <module>()
     28 from ..utils.sparsefuncs import (csc_mean_variance_axis0,
     29                                  inplace_csc_column_scale)
---> 30 from .cd_fast import sparse_std
     31 
     32 

ImportError: No module named cd_fast

并基于此: https://github.com/scikit-learn /scikit-learn/issues/1202

blas可能是错误的?但这是秘密的,我之前有这个问题,但是我只是更新了秘密,应该没问题.

It might be an error with blas? But that's in scipy, and I had problems with that earlier, but I just updated scipy and it should be fine.

请帮助!预先感谢

推荐答案

您忘了编译.在源目录或python setup.py build_ext --inplace中运行python setup.py install,或获取二进制发行版.

You forgot to compile. Run python setup.py install in the source directory, or python setup.py build_ext --inplace, or grab a binary distribution.

(许多scikit-learn实际上是用Cython,C或C ++实现的.您需要C和C ++编译器才能从源代码安装它.)

(Much of scikit-learn is actually implemented in Cython, C or C++. You need C and C++ compilers to install it from source.)

这篇关于在执行教程时使用sklearn遇到ImportError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 05:59