AI智能
改变未来

Raspberry Pi(树莓派) 4B 安装机器学习模块scikit-learn

第一次写博文,仅作记录:

在Raspbian操作系统上安装scikit-learn有些困难(amd32位操作系统难找到合适的包),安装了python3.7.3对应的版本却发现在import sklearn时报错:

[code]/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 usesimport imp

网上有很多解释如何修改,然而水平有限难以改好,于是想在python2.7.16上安装对应的scikit-learn模块吧:

当然树莓派要先换为清华源(或其他国内源)    略

然后安装依赖的三个包:NumPy(树莓派已有)、SciPy和matplotlib

[code]sudo apt-get install python-numpy python-scipy python-matplotlib

成功以后安装scikit-learn

[code]python2 -m pip install -i ASP/ scikit-learn

此处调用清华源的地址,否则下载速度感人

再之后略长的等待build wheel

[code]#下面均为自动进行的…Building wheels for collected packages: scikit-learnBuilding wheel for scikit-learn (setup.py) ... doneCreated wheel for scikit-learn: 略Stored in directory: 略Successfully built scikit-learnInstalling collected packages: scikit-learnSuccessfully installed scikit-learn-0.20.4

大功告成,最后检查一下是否安装成功:

[code]pi@raspberrypi:~ $ python2Python 2.7.16 (default, Oct 10 2019, 22:02:15)[GCC 8.3.0] on linux2Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.>>> import sklearn>>> import numpy>>> import matplotlib>>>

没有报错,可以用树莓派开始机器学习之旅啦!

赞(0) 打赏
未经允许不得转载:爱站程序员基地 » Raspberry Pi(树莓派) 4B 安装机器学习模块scikit-learn