1

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?

1
  • Been there. :) I remember adding something to ~/.bashrc. Not sure though. :( :( Jul 15, 2015 at 10:30

2 Answers 2

1

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 to gksu /usr/bin/idle is all is needed to make this work.

Source: vnc-problem with idle running as sudo on raspberry pi

1
  • Thank 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 click Jul 16, 2015 at 18:00
0

Ok, I found the solution. Follow these steps.

  1. Open .bashrc by nano ~/.bashrc
  2. Paste following code at the end.

    if [ -z "$XAUTHORITY" ]; then
        if [ -e $HOME/.Xauthority ]; then
            export XAUTHORITY=$HOME/.Xauthority;
         fi;
    fi
    
  3. Reboot by sudo reboot to make it effective.

It should work. :)

Hope it helps.

Your Answer

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

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