Ask Your Question
1

python and Yum not runnig due to multiple installations of python

asked 2016-12-27 22:29:05 -0500

Amol Ghodke gravatar image

updated 2016-12-28 00:44:57 -0500

I have this serious problem with my fedora installation. I was trying to use one of my application that requires Python3. So, as a new Linux user, I simply installed python3. Hence my system for two python versions (3 & 2.7). I guess python3 replaced python2.7. Hence "yum" stopped working. I tried to link /usr/bin/python to python2.7 and removing "PYTHONPATH" from .bashrc. Now when i am running-

$python -V

Python2.7.8

When I try to run python itself it returns as -

$ python
 File "/usr/lib64/python3.4/site.py", line 176
   file=sys.stderr)
^
SyntaxError: invalid syntax

when I am running yum I get following result -

$yum
  File "/usr/lib64/python3.4/site.py", line 176
    file=sys.stderr)
^
SyntaxError: invalid syntax

I am thinking of removing all the python versions from the terminal and then reinstall.

Can somebody help me with this situation? Please help me to correct my system!

Thank you Amol

edit retag flag offensive close merge delete

Comments

It seems that PYTHONPATH is still set to /usr/lib64/python3.4. Did you logout/login after removing it from .bashrc? Maybe it is also set somewhere else in /etc/.... For a temporary solution you could set PYTHONPATH to /usr/lib64/python2.7, but it shouldn't be a problem to have both versions installed at the same time. For yum, best would be to replace it with dnf as yum is obsolete these days.

thomaswood gravatar imagethomaswood ( 2016-12-28 04:48:06 -0500 )edit

Thanks ThomasWood, After login/logout things are looking little better. Python started working ( I believe). When I am trying to install packages using Yum following response is coming -

    $ sudo yum install libpng12.x86_64
          Downloading packages:
      File "/usr/libexec/urlgrabber-ext-down", line 28
         except OSError, e:
              ^
    SyntaxError: invalid syntax


 Exiting on user cancel

Could you be able to help me with it?

Amol

Amol Ghodke gravatar imageAmol Ghodke ( 2016-12-28 20:42:43 -0500 )edit

Did you try using dnf instead of yum. yum is deprecated.

thomaswood gravatar imagethomaswood ( 2016-12-29 04:42:46 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
1

answered 2016-12-29 14:41:59 -0500

ssieb gravatar image

Which version of Fedora are you using? There shouldn't be any issues with having both python2 and python3 installed at the same time with a recent Fedora version. And since yum isn't giving you a warning, you must be at least 2 (or 3?) version behind now. I don't think there is any need to have PYTHONPATH set in your .bashrc. It isn't set on any of my systems and python2 and python3 both work fine.

edit flag offensive delete link more

Comments

I am using Fedora 21

Amol Ghodke gravatar imageAmol Ghodke ( 2017-01-01 00:01:12 -0500 )edit

Right, that would be your problem then. Is there some reason you can't use a supported version?

ssieb gravatar imagessieb ( 2017-01-10 16:55:42 -0500 )edit
1

answered 2016-12-30 12:12:37 -0500

andmalc gravatar image

updated 2016-12-30 12:13:28 -0500

The recommended way to set the Python version is to put "#! /usr/bin/env <pyversion>" at the top of the script that runs your application, e.g.

#! /usr/bin/env python3

This way the script will run using the version you want regardless of the system default.

edit flag offensive delete link more
0

answered 2016-12-30 06:20:04 -0500

rhandwor52 gravatar image

Try dnf remove python After version is removed that causes problem. Try dnf install python

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-12-27 22:29:05 -0500

Seen: 2,799 times

Last updated: Dec 30 '16