vnc-problem with idle running as sudo on raspberry pi

Jean Dubois jeandubois314 at gmail.com
Sun Dec 22 08:02:47 EST 2013


I found the following solution to use idle on the raspberry pi
as sudoer (which is necessary or at least comfortable when programming the
GPIO) 
1. Open a terminal
2. type cd ~/Desktop
3. type touch idle_as_root
4. type nano idle_as_root
5. type in sudo idle
6. exit nano
7. type in sudo chmod +x idle_as_root
8. Close terminal
9. Double click on the idle_as_root program on your desktop

This all works fine as long as I use X, however
I also want to use it via vnc
For vnc I did the following:
Installed script "tightvncserver" on the RPiwith the following contents:
#!/bin/bash
# /etc/init.d/tightvncserver
VNCUSER='pi'
case "$1" in
   start)
#    su $VNCUSER -c '/usr/bin/tightvncserver :1'
     su -l $VNCUSER -c '/usr/bin/tightvncserver :1'
     echo "Starting TightVNC server for $VNCUSER "
     ;;
   stop)
     pkill Xtightvnc
     echo "Tightvncserver stopped"
     ;;
   *)
     echo "Usage: /etc/init.d/tightvncserver {start|stop}"
     exit 1
     ;;
esac
exit 0 

sudo chmod 755 /etc/init.d/tightvncserver
sudo update-rc.d tightvncserver defaults

when starting the script manually like this
sudo /etc/init.d/tightvncserver start
everything works as expected i.e. I can click on the idle_as_root-icon and
it works as expected.
If however I reboot the system, the service does start and I do see the
rpi-desktop but clicking the idle_as_root-icon doesn't work. Manually
trying to start it as follows show an error:
pi at raspberrypi ~ $ sudo idle
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, wantobjects, useTk, sync, use)
_tkinter.TclError: couldn't connect to display ":1.0"


Does someone here have a solution for this problem?
thanks in advance
jean



More information about the Python-list mailing list