0

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.

1

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

for me the follwoing worked like a charm. I am installing this in thin-client.pip3 install scikit-learn --index-url piwheels.org/simple
0

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.

5 Comments

It did not work on raspberry pi B (Linux raspbmc 3.12.21 #2 PREEMPT Wed Jun 11 04:53:06 UTC 2014 armv6l GNU/Linux). More specifically: install finished, but scikit-learn cannot run. the problem is that there is no python 3.3 (or higher) distribution for this OS, and scikit-learn requires 3.3. 2 years ago I tried to compile everything, see stackoverflow.com/questions/26677655/…, and it did work. Maybe I should try again, maybe gcc has fix now.
As far as I'm aware, the Pi comes with Python 3 installed; use python3 in the terminal, rather than python?
Yes, python3. python prompt shows python version. What version does it show for you? The highest version of python that I could install on pi is 3.2. And other people have similar experience: raspberrypi.stackexchange.com/questions/15244/…. There are slight differences between 3.2 and 3.3 that break scikit-learn. Newer versions of pi (B2,3) use different processors and might have newer python installed. The bottom line is: not all linuxes are create equal :)
@Dima Ah! I found this thread on the Raspberry Pi forums which looks like it will solve your issue - it contains detailed instructions on building Python 3.5 for the Pi. :) raspberrypi.org/forums/viewtopic.php?f=32&t=123277
Thank you, but I went through this 2 years ago, see link in my first comment. Building scipy was the showstopper. I am trying now Raspbian Jessie, for which python 3.4 was build, but scipy is probably not. It is building numpy now, which takes forever. scipy will be next, and we'll see if gcc fixed that bug I encountered 2 years ago.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.