Which package do i need to use import command?

Hi all,

I tried an shutdown script for my pi. But I get an error when I execute it.
I guess I need an extra package for the import command? But which one is it?

Thats what I installed:

sudo apt-get update
sudo apt-get install python-setuptools
sudo apt-get install python-pip
sudo apt-get install python-dev
sudo apt-get install build-essential
export ARCH=arm
export CROSS_COMPILE=/usr/bin/
sudo pip install wheel
sudo pip install rpi.gpio

But I get an error for my script when i want to use:

  1. import RPi.GPIO as GPIO
  2. import os
  3. import time
  4. GPIO.setmode(GPIO.BOARD)

./shutdown.py: line 4: import: command not found
./shutdown.py: line 5: import: command not found
./shutdown.py: line 6: import: command not found
./shutdown.py: line 8: syntax error near unexpected token GPIO.BOARD' ./shutdown.py: line 8: GPIO.setmode(GPIO.BOARD)’

You are running a python script, so those commands need to be run in a python console, or if they are in a file, make sure that the first line of the file is:


and make the script executable:

chmod u+x myfile.py

then run it:



I’ve done this but now I get this error:

osmc@osmc_2:~$ ./shutdown.py
Traceback (most recent call last):
File “./shutdown.py”, line 11, in
GPIO.setup(7, GPIO.OUT)
RuntimeError: No access to /dev/mem. Try running as root!

I’ve tried already this:

sudo groupadd gpio
sudo usermod -a -G gpio osmc
sudo grep gpio /etc/group
sudo chown root.gpio /dev/gpiomem
sudo chmod g+rw /dev/gpiomem

'What should I do?

Perhaps this will help: OSMC run add-on as root - #6 by dillthedog