LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-18-2006, 09:58 AM   #1
rondo12
LQ Newbie
 
Registered: Jul 2006
Posts: 3

Rep: Reputation: 0
Python trouble


Hi. I'm having some trouble running Python on my DamnSmallLinux machine. As far as I can tell, there are no problems with the main Linux install, but obviously there must be something wrong with the way I've configured Python. Just can't think what.

The Python interpreter path is in bootlocal.sh, so I can run Python interpreter from any directory. All permissions are allowed for all users. BUT, I can't run scripts. I set my script and also the Python interpreter to chmod 755, but it doesn't work. The error message is:

Bad interpreter: Permission denied

The command-line interpreter works fine by itself: it's just scripts it can't seem to execute. It doesn't even get to the first line in the script. It just returns the error message above.

So I checked my fstab, and yes on all partitions "exec" is set, and so is "users". So I assume fstab settings aren't the problem. The Python 2.3 package I'm using is the standard stable one from my distro's official website, so obviously it can't be a line-endings problem from a package put together under Windows.

Any ideas?
 
Old 07-18-2006, 10:22 AM   #2
jayemef
Member
 
Registered: Aug 2005
Location: Juniata College, PA
Distribution: Ubuntu, Slackware
Posts: 67

Rep: Reputation: 15
When running your scripts, are you using
Code:
$ python filename.py
or are you relying on the shebang by using
Code:
$ ./filename.py
Your error sounds like you are using the wrong shebang, and thus coming up with the wrong interpreter. I usually use
Code:
#!/usr/bin/env python
The command which python will tell you exactly where your interpreter is located.


Also, for future reference, you can use apt to install python in DSL:
Code:
$ sudo dpkg-restore
$ sudo apt-get update
$ sudo apt-get install python
There should be a way to install it via DSL's own tools, but I've never taken the time to learn how.

Last edited by jayemef; 07-18-2006 at 10:27 AM.
 
Old 07-18-2006, 12:15 PM   #3
rondo12
LQ Newbie
 
Registered: Jul 2006
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks jayemef. Python is located in opt/python/bin, and to run my scripts I just enter the name of the script, e.g. script.py into bash. The first line of the script is:

#!/opt/python/bin python

I didn't use apt-get to install this Python, because the DSL computer is not connected to the internet. I instead got the Python tarball from the DSL website (from distro, ibiblio):

pub/linux/distributions/damnsmall/mydsl/system/

As it didn't have the .dsl extension, it was not possible to use the MyDSL facility to install this app. So I just put it in /opt so that it would be included as a startup program. Do you think this could be the problem?
 
Old 07-18-2006, 12:42 PM   #4
jayemef
Member
 
Registered: Aug 2005
Location: Juniata College, PA
Distribution: Ubuntu, Slackware
Posts: 67

Rep: Reputation: 15
Nope, shouldn't be a problem -- particularly if you can use python in interactive mode. Try changing your shebang to
Code:
#!/opt/python/bin/python
and see if that helps.
 
Old 07-18-2006, 06:05 PM   #5
rondo12
LQ Newbie
 
Registered: Jul 2006
Posts: 3

Original Poster
Rep: Reputation: 0
Wow!! It works! Been spending 3 days tearing my hair out over that: and it turns out it was fixable with a single slash. Great website, this. Thanks Jayemef.

Quote:
Originally Posted by jayemef
Nope, shouldn't be a problem -- particularly if you can use python in interactive mode. Try changing your shebang to
Code:
#!/opt/python/bin/python
and see if that helps.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Move to python 2.4 / Changing the packaging style for python packages LXer Syndicated Linux News 0 06-13-2006 08:54 PM
python problem - compiled from source - python -V still showing old version txm123 Linux - Newbie 1 02-15-2006 12:05 PM
Trouble installing Python 2.3 on SuSE 9 system Wandering Idiot Linux - Software 2 09-22-2004 01:47 AM
Trouble Python Code Gerardoj Programming 0 11-30-2003 05:31 PM
importing trouble....python...regarding Tkinter maseby Programming 0 11-03-2003 02:54 PM


All times are GMT -5. The time now is 06:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration