Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I've got a python script that uses sys.platform.startswith('linux') to test if it is on linux or not, but then I can't tell the difference between the x86/64 processor, and the raspberry pi's ARM processor.

The reason I need this, is to run an external script that's compiled for either mac, linux x86/64, or linux ARM for the raspberry pi.

From what I can tell, there's not really a unified way to tell that you are in fact running on a raspberry pi. Any help would be appreciated.

share|improve this question
Can you use os.uname() to obtain this information? –  milancurcic Feb 24 '13 at 17:12
Will that work on all distros for raspberry pi? On raspbian wheezy, it seems to work. –  jnesselr Feb 24 '13 at 17:30

1 Answer 1

up vote 4 down vote accepted

You can use Python's os module to obtain this information through uname:

import os

This function should provide platform and other information on most Linux or Unix-like distributions.

From the Python documentation:


Return a 5-tuple containing information identifying the current operating system. The tuple contains five strings: (sysname, nodename, release, version, machine). Some systems truncate the nodename to eight characters or to the leading component; a better way to get the hostname is socket.gethostname() or even socket.gethostbyaddr(socket.gethostname()).

Availability: recent flavors of Unix.

share|improve this answer
os.uname()[4][:3] == 'arm' –  OrangeTux Jul 6 '13 at 13:09
Anyone who looks at this now, we ended up doing os.uname()[4].startsWith("arm") to check. –  jnesselr Jan 26 '14 at 7:27
@jnesselr tiny typo, it is startswith, not startsWith. Thanks, it helped. –  Nishant Oct 4 '14 at 9:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.