Raspberry Test Problem

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
User avatar
geotek
 
Posts: 65
Joined: Thu Mar 07, 2013 1:39 pm

Raspberry Test Problem

Post by geotek »

I'am new to Raspberry Pi and Python.
If I go to the LX terminal and type in a program using sudo python and "program-name' the program works BUT if I go to IDLE3 and call up the program and go to the RUN box to try and Run the same program, I get syntax error messages -- why can't I just call up the program and run it from IDLE?
Tom

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Raspberry Test Problem

Post by adafruit_support_mike »

(Moved the topic over to the Raspberry Pi forum)

You're probably seeing a permissions issue. When you execute python with sudo, that process gets the root user's access priviliges. When you run the IDE, it runs with your user account's permissions. I doubt the 'Run' button would have privilege escalation built in.

What are you running that needs root access?

User avatar
geotek
 
Posts: 65
Joined: Thu Mar 07, 2013 1:39 pm

Re: Raspberry Test Problem

Post by geotek »

Actually its program demo for bmp085 pressure sensor from adafruit
If I run program from command line using sudo command, the program runs fine, but if I use Idle to run program it won't work, but returns error message.
Other programs work similarly, if I use command line they work fine
What am I missing?

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Raspberry Test Problem

Post by adafruit_support_mike »

It's very likely that the script files belong to the root user and your regular login account doesn't have permission to execute them.

Go to the command line, use the 'cd' command to navigate to the directory where your scripts live, and type 'ls -lR'. That will show you a list of everything in that part of the file tree. It will also have information about the specific files, like who owns them and who has permission to use them:

Code: Select all

-rw-r--r--  1 www  www    694 May 12  2010 index.html
-rw-r--r--  1 www  www  46162 May 12  2010 pencil.jpg
-rw-r--r--  1 www  www   1140 May 12  2010 s0-parts.html
-rw-r--r--  1 www  www  15580 May 12  2010 s0-pencil.jpg
-rw-r--r--  1 www  www  19967 May 12  2010 s0-solder.jpg
-rw-r--r--  1 www  www  22540 May 12  2010 s1-final.jpg
-rw-r--r--  1 www  www   3632 May 12  2010 s1-make.html
-rw-r--r--  1 www  www  28096 May 12  2010 s1.1-pull-lead.jpg
-rw-r--r--  1 www  www  22261 May 12  2010 s1.2-cut-solder.jpg
-rw-r--r--  1 www  www   1394 May 12  2010 style.css
The '-rw-r-r--' stuff along the left says that only the file's owner is allowed to write to those files, but anyone can read the files. The first 'www' is the name of the user account that owns the files, and the second 'www' is the name of the group the user belongs to.

My guess is that you'll see something like:

Code: Select all

-rwxr--r--  1  root  wheel  12345  March 24 some-script.py
which says the root account owns the file, and only the root account has permission to change the file or execute it as a script.

The solution is to change the ownership of the files:

Code: Select all

chown -R pi *
assuming you're logging in as the default 'pi' user. If not, replace 'pi' with the name of your account.

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”