I am trying to run idle with root privileges so as to use the RPi.GPIO module.
The RPi 2 is headless and I am using TightVNC Server. I get the error
Client is not authorized to connect to ServerTraceback
From googling I have discovered that this is a conflict with VNC but I have not been able to find a solution.
Strangely I somehow managed to resolve this problem when using the old Model B but I stupidly did not make a note of how.
Can anybody help?
2 Answers 2
Try this:
Run the vncserver as root
sudo vncserver
connect to the root vnc session then run
sudo DISPLAY=:2 idle
# with the right number for root's VNC.
Source: trouble running idle as a root using vnc
If that doesn't work, then something is up with XAUTHORITY.
Try adding
xhost +local:root
to .bashrc
as dastaan suggests.
Just seen this:
In fact no need for that, changing
sudo /usr/bin/idle
togksu /usr/bin/idle
is all is needed to make this work.
Source: vnc-problem with idle running as sudo on raspberry pi
-
1Thank you greenonline gksu /usr/bin/idle does it. For those who see this you can find the file to change by Menu>programing>Python(2/3) and then right clickAlan Johnstone– Alan Johnstone2015年07月16日 18:00:32 +00:00Commented Jul 16, 2015 at 18:00
Ok, I found the solution. Follow these steps.
- Open
.bashrc
bynano ~/.bashrc
Paste following code at the end.
if [ -z "$XAUTHORITY" ]; then if [ -e $HOME/.Xauthority ]; then export XAUTHORITY=$HOME/.Xauthority; fi; fi
- Reboot by
sudo reboot
to make it effective.
It should work. :)
Hope it helps.
~/.bashrc
. Not sure though. :( :(