windy54
Posts: 99
Joined: Sat Dec 29, 2012 3:37 pm

Running Python via VNC

Thu Feb 07, 2013 3:44 pm

Hi,

Hope this post is in the correct place!

I am running raspbian wheezey and following Neil Blacks blog I have managed to connect to the PI using VNC.

Also, following Matt Dyson's blog I have managed to control a maplins robotic arm from a joystick.

When the PI is connected to a TV I type in
sudo python RobotArm.py

and I can control the arm.

Now I have had to move away from the TV I am using VNC to connect to the PI.
I naively thought that the same command entered through VNC would work, silly me !

I get the following output
"client is not authorized to connect to ServerClient is not authorized to connect to ServerClient is not authorized to connect to Serverxcb_connection_has_error() returned true.
Client is not authorized to connect to Serverxcb_connection_has_error() returned true."

Can anyone please shed any light on what the problem is, I am guessing it is a privilege setting somewhere.

I have started to search the web but cant find anything that makes sense, to me that is !

thanks

Steve

cae2100
Posts: 143
Joined: Tue Jan 08, 2013 10:35 am
Contact: Website

Re: Running Python via VNC

Sun Feb 10, 2013 7:10 am

the vnc server is trying to run everything in like a protected mode. try running it as sudo when running the program or SSH'ing into the rpi and using it that way.
If it isnt smoking and blown into pieces, it's not pushed far enough yet. :P
http://cae2100.wordpress.com

windy54
Posts: 99
Joined: Sat Dec 29, 2012 3:37 pm

Re: Running Python via VNC

Fri Feb 15, 2013 6:33 pm

Thanks for the response.
I had tried SSH before and it did not seem to work, however , previously I closed the window. Today I did a CTRL-C, got an error message and then it worked.
The program actually opens another window which I do not see using SSH, not sure whether the CTRL-C did something to the other window, when I get a chance I will look at the program and see if it needs to open another window.

As for VCN, that still does not work.
I have used some code from Neil Black's blog for beginers and entered the following script:
"
Create a new file in the init.d directory:

sudo nano /etc/init.d/tightvncserver
Enter the following details:

#!/bin/sh
# /etc/init.d/tightvncserver
VNCUSER='pi'
case "$1" in
start)
su $VNCUSER -c '/usr/bin/tightvncserver :1'
echo "Starting TightVNC Server for $VNCUSER "
;;
stop)
pkill Xtightvnc
echo "TightVNC Server stopped"
;;
*)
echo "Usage: /etc/init.d/tightvncserver {start|stop}"
exit 1
;;
esac
exit 0
"

In an attempt to follow your suggestion I change the line su $VNCUSER -c '/usr/bin/tightvncserver :1'
to
sudo su $VNCUSER -c '/usr/bin/tightvncserver :1'

I need to dig a bit further and understand the su command and possibly try something like
su $VNCUSER -c 'sudo /usr/bin/tightvncserver :1'

so that tightvncserver runs as sudo and not the su command.

Thanks for the response, I will post another reply when I have had chance to try it.

Steve

cae2100
Posts: 143
Joined: Tue Jan 08, 2013 10:35 am
Contact: Website

Re: Running Python via VNC

Sat Feb 16, 2013 1:11 am

I didnt mean running the vnc server as root, but just using sudo to elevate python to root. like sudo python program.py whenever youre using the terminal in vnc.
If it isnt smoking and blown into pieces, it's not pushed far enough yet. :P
http://cae2100.wordpress.com

windy54
Posts: 99
Joined: Sat Dec 29, 2012 3:37 pm

Re: Running Python via VNC

Sat Feb 16, 2013 10:15 am

I have to do that when running the python program directly from the PI so that it can access the USB port, so I was doing it when in VNC mode as well.

thanks for the response

Return to “Python”