LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-15-2005, 05:26 PM   #1
zirtik
Member
 
Registered: Jul 2005
Posts: 33

Rep: Reputation: 15
Python doesn't work


Hello all, i'm a linux newbie so please forgive me for silly questions.

I cannot execute any .py files, when i type for example

filename.py i get no output, just nothing happens. python is located at /usr/bin/python and i put a
#!/usr/bin/python shebang at the beginnig. I cannot execute any of them. This problem occured a few days ago and i did not make any system changes - i guess.

Before that, typing

python -V

used to give me the output:

Python 2.2.3

but now i get nothing, it simply gives no output and gets back to terminal screen for a new command.Basically it looks like as follows:

#python -V
#

I use fedora core 1 on a PIII 550 mhx cpu with 256 mb memory.
I have root access and tried everything. Please help. Thanks in advance.
 
Old 10-15-2005, 05:34 PM   #2
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 34
Hmmm, what do you get from 'which python'? Perhaps you've accidentally created a script called python which is getting found instead of the real thing.
 
Old 10-15-2005, 05:53 PM   #3
zirtik
Member
 
Registered: Jul 2005
Posts: 33

Original Poster
Rep: Reputation: 15
which python

gives me the following:

/usr/bin/python

any ideas now?
 
Old 10-15-2005, 06:12 PM   #4
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 34
So, really nothing is happening? You get nothing from, say, python -c 'print "hello"'

If not, run

Code:
strace python -c 'print "hello"' 2> strace-log
and post it. strace traces system calls and is very useful for determining what a command is doing.
 
Old 10-15-2005, 06:15 PM   #5
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Maybe he has forgotten to make the script executable?

Code:
chmod u+x script_here
Also, you can just run the script by using python directly.

Code:
python script_here
 
Old 10-15-2005, 06:17 PM   #6
zirtik
Member
 
Registered: Jul 2005
Posts: 33

Original Poster
Rep: Reputation: 15
Good news!

I tried python2.4 -V and get a version number! Also changing the shebang

from

!/usr/bin/python

to

!/usr/bin/python2.4 solved the problem. Now I have another question:

Since this is a temporary solution and some other scripts using /usr/bin/python will malfunction, how can i make python2.4 to work each time i type

#python

on the terminal?

[root@didem bin]# ls -al /usr/bin/pyth*

gives the following output:

-rwxr-xr-x 2 root root 0 Eki 12 21:47 /usr/bin/python
lrwxrwxrwx 1 root root 6 Eki 6 18:27 /usr/bin/python2 ->
python
-rwxr-xr-x 2 root root 0 Eki 12 21:47 /usr/bin/python2.2
-rwxr-xr-x 2 root root 5920 Haz 21 08:00 /usr/bin/python24
-rwxr-xr-x 2 root root 5920 Haz 21 08:00 /usr/bin/python2.4




Any help will be appreciated, thanks inadvance!
 
Old 10-15-2005, 06:20 PM   #7
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
That does not make any sense. Based on the results of your
Code:
which
command, your sha-bang line should read:
Code:
#!/usr/bin/python
Also:
Quote:
[root@didem bin]# ls -al /usr/bin/pyth*
Why in the world are you running scripts as root?
 
Old 10-15-2005, 06:31 PM   #8
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 34
Quote:
-rwxr-xr-x 2 root root 0 Eki 12 21:47 /usr/bin/python
So /usr/bin/python is empty (zero size)?? This makes no sense. Looks like you've munged the file.

If python2.4 works, then just symlink /usr/bin/python to that (cd /usr/bin && ln -s python2.4 python).

As for python2.2, looks like you'd be better off uninstalling/reinstalling it.

And yes, you shouldn't be running as root.
 
Old 10-15-2005, 07:13 PM   #9
zirtik
Member
 
Registered: Jul 2005
Posts: 33

Original Poster
Rep: Reputation: 15
Smile

Thank you all, everything is solved and yes, you're right about not running as root,

cheers
 
Old 10-17-2005, 05:28 AM   #10
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
running as root is probably the reason for:
Quote:
-rwxr-xr-x 2 root root 0 Eki 12 21:47 /usr/bin/python
 
  


Reply



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
Processing Conflict: python-devel conflicts python< 2.3.4-13.1 guarriman Fedora 2 04-23-2009 07:02 PM
newbie, getting simple python script to work Monjawi Programming 6 10-03-2005 11:51 AM
getting wxPython to work with python servnov Linux - Newbie 0 01-09-2005 11:48 AM
python doesn´t work little_ball Linux - Newbie 4 12-04-2004 09:09 AM
Python XML won't work. Travis86 Programming 0 09-14-2004 05:13 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:43 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
Open Source Consulting | Domain Registration