raise RuntimeError('Error accessing GPIO.') RuntimeError: Error accessing GPIO.

C++
The RPi.GPIO Python module is bundled with Raspbian.

Currently RPi.GPIO has to be run with root priviliges because it accesses /dev/mem. You need root priviliges to access /dev/mem.

So you have to run RPi.GPIO with sudo or similar.
Source

Also in C++: