第一次写博文,仅作记录:
在Raspbian操作系统上安装scikit-learn有些困难(amd32位操作系统难找到合适的包),安装了python3.7.3对应的版本却发现在import sklearn时报错:
/usr/lib/python3/dist-packages/sklearn/externals/joblib.py:1: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
网上有很多解释如何修改,然而水平有限难以改好,于是想在python2.7.16上安装对应的scikit-learn模块吧:
当然树莓派要先换为清华源(或其他国内源) 略
然后安装依赖的三个包:NumPy(树莓派已有)、SciPy和matplotlib
sudo apt-get install python-numpy python-scipy python-matplotlib
成功以后安装scikit-learn
python2 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple scikit-learn
此处调用清华源的地址,否则下载速度感人
再之后略长的等待build wheel
#下面均为自动进行的…
Building wheels for collected packages: scikit-learn
Building wheel for scikit-learn (setup.py) ... done
Created wheel for scikit-learn: 略
Stored in directory: 略
Successfully built scikit-learn
Installing collected packages: scikit-learn
Successfully installed scikit-learn-0.20.4
大功告成,最后检查一下是否安装成功:
pi@raspberrypi:~ $ python2
Python 2.7.16 (default, Oct 10 2019, 22:02:15)
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sklearn
>>> import numpy
>>> import matplotlib
>>>
没有报错,可以用树莓派开始机器学习之旅啦!