LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS
User Name
Password
CentOS This forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation.

Notices


Reply
  Search this Thread
Old 06-16-2017, 09:54 AM   #1
usao
Member
 
Registered: Dec 2011
Location: Chandler, AZ
Posts: 286

Rep: Reputation: Disabled
yum syntax error?


CentOS 7.3
Started getting a syntax error from the yum command... Any suggestions other than rolling back to Pythoh 2.7?

Code:
# yum update -y
  File "/usr/bin/yum", line 30
    except KeyboardInterrupt, e:
                            ^
SyntaxError: invalid syntax
The /usr/bin/yum appears to be a python script.
The error started after I upgraded to Python 3.5.2.

Code:
# python -V
Python 3.5.2
 
Old 06-16-2017, 10:10 AM   #2
Demosa
Member
 
Registered: Feb 2013
Distribution: Fedora 25, RHEL7, RHCI stack
Posts: 38

Rep: Reputation: Disabled
Odd, can you run
Code:
yum info yum
I doubt it's python
 
Old 06-16-2017, 10:35 AM   #3
usao
Member
 
Registered: Dec 2011
Location: Chandler, AZ
Posts: 286

Original Poster
Rep: Reputation: Disabled
No, same issue.
When I switch back to python 2.7 yum works correctly.
 
Old 06-16-2017, 10:39 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,078

Rep: Reputation: 7364Reputation: 7364Reputation: 7364Reputation: 7364Reputation: 7364Reputation: 7364Reputation: 7364Reputation: 7364Reputation: 7364Reputation: 7364Reputation: 7364
switch back from where? python 3.x and 2.x are not compatible with each other.
 
Old 06-16-2017, 10:47 AM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,784

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
/usr/bin/yum is most definitely a Python script, but it's for Python 2. If you installed Python 3 in place of Python 2, or made Python 3 the default, that's going to break many things on your system. You can install Python 3.x alongside Python 2, but Python 2 needs to remain the default. There is a Python 3.4 package (python34-3.4.5-4.el7) available for CentOS 7 from the epel repo. I don't know of any Python 3.5 package that has been built for CentOS.
 
Old 06-16-2017, 11:05 AM   #6
usao
Member
 
Registered: Dec 2011
Location: Chandler, AZ
Posts: 286

Original Poster
Rep: Reputation: Disabled
I have both versions of python installed. The default CentOS 7.3 is Python 2.7, while I also installed Python 3.5.2.
When the root account is configured to use Python 3.5.2 I get the 'yum' error as shown above. When I switch back to using Python 2.7 then 'yum' works.
 
Old 06-16-2017, 11:25 AM   #7
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,784

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
It's a basic "Doc, it hurts when I do this," : "Don't do that" issue. If you set up an environment to use Python 3.x, then any system Python scripts you launch from that environment are going to fail.
 
Old 06-16-2017, 11:39 AM   #8
usao
Member
 
Registered: Dec 2011
Location: Chandler, AZ
Posts: 286

Original Poster
Rep: Reputation: Disabled
How can one identify the necessary fixed to get CentOS 7.3 to work properly with the installed Python version?
Version 2.7 is horribly out of date, and even 3.5.2 is still out of date and needs to get pushed further forward.
This seems to be a flaw in the design of CentOS in that it's using critically out of date software and doesn't appear to be making any effort to bring things up to proper levels.
Many places I have researched on the web are saying to get off 2.7 as soon as possible, but it seems the OS it tied to this out of date version.
This needs to get addressed as soon as possible.
 
Old 06-16-2017, 11:48 AM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,078

Rep: Reputation: 7364Reputation: 7364Reputation: 7364Reputation: 7364Reputation: 7364Reputation: 7364Reputation: 7364Reputation: 7364Reputation: 7364Reputation: 7364Reputation: 7364
Why do you think that? python 2.x and 3.x are not compatible with each other, and 2.x is not outdated at all. see for example here: https://www.python.org/downloads/
CentOS is not tied to python 2, but huge amount of apps are implemented using python 2 and actually (almost) impossible to reimplement all of them with python 3 quickly. This is valid for all linux distros including debian, ubuntu, centos and (almost) all of them.
 
Old 06-16-2017, 12:31 PM   #10
DavidMcCann
LQ Veteran
 
Registered: Jul 2006
Location: London
Distribution: PCLinuxOS, Salix
Posts: 6,153

Rep: Reputation: 2316Reputation: 2316Reputation: 2316Reputation: 2316Reputation: 2316Reputation: 2316Reputation: 2316Reputation: 2316Reputation: 2316Reputation: 2316Reputation: 2316
Quote:
Originally Posted by usao View Post
This seems to be a flaw in the design of CentOS in that it's using critically out of date software and doesn't appear to be making any effort to bring things up to proper levels.
CentOS is basically a free version of Red Hat. People who run their businesses with RHEL don't want the latest stuff, they want the tried and tested stuff. The same goes for most CentOS users (who run half the internet). If you try to make CentOS "up-to-date" you will have problems. If you feel that you really need to do it, then it's probably a sign that you shouldn't be using CentOS in the first place!
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Yum not working at all due to /usr/bin/yum syntax error aheusdens Linux - General 1 04-09-2010 04:15 PM
Yum fails with perl syntax error pawprint_net Linux - Software 4 03-05-2010 05:13 PM
[python] syntax Error : invalid syntax Python_user Programming 2 09-06-2009 12:52 PM
C++ syntax error before :: token HELP, i cant find the syntax error :( qwijibow Programming 2 12-14-2004 06:09 PM
YUM Syntax? Emanon247 Linux - Newbie 1 07-22-2004 04:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS

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