简体   繁体   中英

How can I run python scikit-learn on Raspberry Pi?

I'm new in embedded programming, and would like to understand what I need to do to run python scikit-learn on a capable embedded processor.
See Raspberry Pi as an example.

First things first: I think it's a good practice to develop in virtual environments, as opposed to installing everything system-wide. Therefore, I suggest you go ahead and spin up one for Python 3.

sudo pip3 install virtualenv
virtualenv -p python3 .venv
source .venv/bin/activate

Once you have that, install the dependencies for scikit-learn .

sudo apt-get update 
sudo apt-get install gfortran libatlas-base-dev libopenblas-dev liblapack-dev -y

And lastly, let's install the actual scikit-learn library. Instead of just pip installing it, which will proceed on compiling the whole stuff, which takes a lot of time, just use the wheel from piwheels.org.

pip3 install scikit-learn --index-url https://piwheels.org/simple

And that's it. Now, having said that, please be aware of the available wheels for a given version of Python. For instance, at this moment, the scikit-learn library is only available to 3.4.x/3.5.x versions of it. That's an okay thing, as Python 3.5.x is already present on Raspbian.

scikit-learn will run on a Raspberry Pi just as well as any other Linux machine.

To install it, make sure you have pip3 ( sudo apt-get install python3-pip ), and use sudo pip3 install scikit-learn .

All Python scripts utilizing scikit-learn will now run as normal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM