1

When I type the sudo idle command into the terminal it returns this error message.

Client is not authorized to connect to ServerTraceback (most recent call last):
File "/usr/bin/idle", line 5, in <module> main()
File "/usr/lib/python2.7/idlelib/PyShell.py, line 1427, in main
root = Tk(className="Idle")
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1712, in _init_
self.tk = _tkinter.create(screenName, baseName, className, interactive, want
objects, useTk, sync, use)
_tkinter.TclError: couldn't connect to display ":2.0"

I am using Raspbian Wheezy and a TightVNC server to run my Pi.

1
  • 1
    Does it work withoud sudo? Unless you are doing something unusual you should no longer be using sudo with Python.
    – joan
    Commented Nov 26, 2015 at 16:57

3 Answers 3

2

Try adding this to /etc/sudoers

Defaults    env_reset
Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Defaults    env_keep += "DISPLAY"
Defaults    env_keep += "XAUTHORITY"

And this to ~/.bashrc

if [ -z "$XAUTHORITY" ]; then
    if [ -e $HOME/.Xauthority ]; then
        export XAUTHORITY=$HOME/.Xauthority;
    fi;
fi

Got it from https://stackoverflow.com/questions/20286705/tkinter-through-vnc-without-physical-display

2
  • Thanks guys, ill check it out later and let you know what happens :) Commented Nov 27, 2015 at 7:13
  • This is probably the correct answer. Don't we all love "contributors" who ask questions, promise to follow up and then disappear?
    – Seamus
    Commented May 20, 2022 at 0:21
0

I think usually the direct video output from the Pi (either over analogue or HDMI) occupies display :0. The error is talking about display :2.0 which to me suggests that you have two VNC servers running, one on :1.0 and one on :2.0. This could cause confusion - especially if there is no client connected to :1.0 (I don't think it will even open anything there as there is nothing to 'show' it and will therefor error out).

Try stopping all VNC servers and starting one and reconnect from your viewer.

-1

you can always open IDLE by just typing in

idle
1
  • 1
    Doesn't this beg the question? The OP stated that they entered this at the command line. If you're drawing a distinction because you didn't do it with sudo, you should explain why that's significant.
    – Brick
    Commented Dec 20, 2018 at 14:38

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.