LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-20-2015, 04:20 AM   #1
knitinfk
LQ Newbie
 
Registered: Jul 2015
Posts: 8

Rep: Reputation: Disabled
yum is not working throwing error


Hi,

yum is throwing the following error

[root@localhost bin]# yum update
bash: /bin/yum: /usr/bin/python: bad interpreter: No such file or directory


i am running a fedora 21..

python version is Python 3.4.3


Looking forward for your help in resolving this problem..


Thanks
 
Old 07-20-2015, 04:39 AM   #2
yerunkar11
LQ Newbie
 
Registered: Mar 2015
Posts: 24

Rep: Reputation: Disabled
http://stackoverflow.com/questions/1...when-using-yum

---------- Post added 07-20-15 at 03:10 PM ----------

http://www.linuxquestions.org/questi...rector-933911/
 
Old 07-20-2015, 05:09 AM   #3
knitinfk
LQ Newbie
 
Registered: Jul 2015
Posts: 8

Original Poster
Rep: Reputation: Disabled
Hi,

thanks for the urls.. but i have tried but it didn't really work..

Do i need to change any of the yum configuration?
 
Old 07-20-2015, 06:02 AM   #4
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
So, does /usr/bin/python exist, and is it executable?
What happens when you simply type /usr/bin/python?
 
Old 07-20-2015, 06:50 AM   #5
knitinfk
LQ Newbie
 
Registered: Jul 2015
Posts: 8

Original Poster
Rep: Reputation: Disabled
Hi,

I have made some progress, have changed the /bin/yum to #!/usr/bin/python2 and now it is throwing this error

[root@localhost]# yum update
File "/bin/yum", line 30
yummain.main (sys.argv[1:])
^
IndentationError: expected an indented block
[root@localhost]#

Last edited by knitinfk; 07-20-2015 at 07:07 AM.
 
Old 07-20-2015, 03:24 PM   #6
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
yum is deprecated and not used any more
the current tool is

DNF


as to yum
did you replace the DEFAULT version of python ?
yum in f21 still used python2.6 i believe

the DEFAULT version of python from the fedora 21 base or update repo MUST!!! 100% MUST BE SET as the default python
 
Old 07-20-2015, 05:49 PM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by John VV View Post
yum is deprecated and not used any more
No, that's slated for F22 AFAIK.


Quote:
Originally Posted by John VV View Post
did you replace the DEFAULT version of python ?
yum in f21 still used python2.6 i believe
He must have. F21 comes with python-2.7.something.
 
Old 07-20-2015, 11:33 PM   #8
knitinfk
LQ Newbie
 
Registered: Jul 2015
Posts: 8

Original Poster
Rep: Reputation: Disabled
Hi John,

i have upgraded python and the current python version is 3.4.3.

Do you mean to say yum works only with 2.6 python?

I wanted to execute python scripts on my fedora also so i have upgraded python.

Thanks..
 
Old 07-20-2015, 11:54 PM   #9
knitinfk
LQ Newbie
 
Registered: Jul 2015
Posts: 8

Original Poster
Rep: Reputation: Disabled
Hi john,

I have uninstalled 3.4 and installed 2.7 python but still i get the same error..

[root@localhost bin]# yum update
File "/bin/yum", line 30
yummain.main (sys.argv[1:])
^
IndentationError: expected an indented block


Thanks..
 
Old 07-21-2015, 12:12 AM   #10
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Can you show the first 35 lines or so of /usr/bin/yum (which is likely to be all of /usr/bin/yum)?
Perhaps your tinkering with the file has removed indentation.

For comparison: On my system, Centos 6.6, the corresponding lines in /usr/bin/yum look like this:
Code:
sys.path.insert(0, '/usr/share/yum-cli')
try:
    import yummain
    yummain.user_main(sys.argv[1:], exit_code=True)
except KeyboardInterrupt, e:
    print >> sys.stderr, "\n\nExiting on user cancel."
    sys.exit(1)
This runs with Python 2.6.6.

I also have a Centos 7 machine, where it looks the same, and uses Python 2.7.5
 
Old 07-21-2015, 12:29 AM   #11
knitinfk
LQ Newbie
 
Registered: Jul 2015
Posts: 8

Original Poster
Rep: Reputation: Disabled
output of /usr/bin/yum

import sys
20 import os
21 sys.path.insert(1,'/usr/share/yum')
22 import yummain
23 from i18n import _
24 import yumlock
25
26 uid = os.geteuid()
27 lockfile = '/var/run/yum.pid'
28
29 try:
30 yummain.main (sys.argv[1:])
31 except SystemExit, e:
32 if e.code != 200:
33 if uid == 0:
34 yumlock.unlock(lockfile)
35 sys.exit(e)
36 except KeyboardInterrupt, e:
37 print _('Exiting on User Cancel')
38 if uid == 0:
39 yumlock.unlock(lockfile)
40 sys.exit(1)
41 except IOError, (errno, strerror):
42 print _('IOError - # s - %s') % (errno, strerror)
43 if uid == 0:
44 yumlock.unlock(lockfile)
45 sys.exit(1)



thanks
 
Old 07-21-2015, 12:52 AM   #12
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by knitinfk View Post
output of /usr/bin/yum

import sys
20 import os
21 sys.path.insert(1,'/usr/share/yum')
22 import yummain
23 from i18n import _
24 import yumlock
25
26 uid = os.geteuid()
27 lockfile = '/var/run/yum.pid'
28
29 try:
30 yummain.main (sys.argv[1:])
31 except SystemExit, e:
32 if e.code != 200:
33 if uid == 0:
34 yumlock.unlock(lockfile)
35 sys.exit(e)
36 except KeyboardInterrupt, e:
37 print _('Exiting on User Cancel')
38 if uid == 0:
39 yumlock.unlock(lockfile)
40 sys.exit(1)
41 except IOError, (errno, strerror):
42 print _('IOError - # s - %s') % (errno, strerror)
43 if uid == 0:
44 yumlock.unlock(lockfile)
45 sys.exit(1)
Add two spaces at the beginning of line 30. That should rid you of the latest error.

Unlike free-format langages like C, which use special characters like { and } for their block structure, Python requires indentation to indicate a new block.
 
Old 07-21-2015, 12:54 AM   #13
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Also use code tags instead of quote tags for computer text. Quote makes your indentation disappear.
 
Old 07-21-2015, 01:25 AM   #14
knitinfk
LQ Newbie
 
Registered: Jul 2015
Posts: 8

Original Poster
Rep: Reputation: Disabled
sorry for asking this again...

can you please highight the changes you have done for /usr/bin/python.

Thanks
 
Old 07-21-2015, 01:29 AM   #15
knitinfk
LQ Newbie
 
Registered: Jul 2015
Posts: 8

Original Poster
Rep: Reputation: Disabled
Hi,

I have added two spaces before line 30 and when i execute yum update i get the following error..

[root@localhost bin]# yum update
Traceback (most recent call last):
File "/bin/yum", line 22, in <module>
import yummain
File "/usr/share/yum/yummain.py", line 22, in <module>
import clientStuff
File "/usr/share/yum/clientStuff.py", line 18, in <module>
import rpm
ImportError: No module named rpm
[root@localhost bin]# vi /usr/bin/yum
[root@localhost bin]# yum update
File "/bin/yum", line 22
import yummain
^
IndentationError: unexpected indent
 
  


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
yum working fine on server and ftp is working f9 but not able to config yum on client joj123 Red Hat 12 01-13-2015 06:03 PM
Yum not working at all due to /usr/bin/yum syntax error aheusdens Linux - General 1 04-09-2010 04:15 PM
SQUINT throwing error's ... sco1984 SUSE / openSUSE 1 07-23-2008 11:46 PM
RPM Command not working, throwing undefined symbol error racurtis Linux - Software 2 04-03-2007 01:19 PM
SuSE YOU - throwing error neocookie Linux - Software 3 10-25-2004 02:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:01 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