Broke my centos7 VPS when trying to update Python

Issues related to applications and software problems
water
Posts: 7
Joined: 2018/08/07 09:58:53

Broke my centos7 VPS when trying to update Python

Post by water » 2018/08/07 10:02:03

I followed this guide in order to update python running on my Centos7 vps. unfortunately this messed some things up. I didn't know that centos7 relied on python 2.7.

Im now unable to perform yum or any other commands. I don't know where to start to fix this problem as I want to revert back to my old Python version of 2.7.5(-58.el7)

when performing yum I get: No module named yum

What is the best way to revert my noob changes:)?

User avatar
avij
Retired Moderator
Posts: 3046
Joined: 2010/12/01 19:25:52
Location: Helsinki, Finland
Contact:

Re: Broke my centos7 VPS when trying to update Python

Post by avij » 2018/08/07 10:09:48

Looking through that document it looks like it would install Python 3.6 in parallel to your existing CentOS-provided python, so it should not break yum.

Did you deviate from those instructions somehow?

water
Posts: 7
Joined: 2018/08/07 09:58:53

Re: Broke my centos7 VPS when trying to update Python

Post by water » 2018/08/07 10:32:07

yes, I tried to enable it since the output of python --version was 2.7.5. and I wanted it to have on version 3. Think it was the commands below which messed things up

scl enable python36u bash
sudo ln -fs /usr/bin/python3 /usr/bin/python

I do have a log file of the commands I used in order to update python. But it's a long list. I went pretty nuts on trying to get python 3 running :) fully unexperienced and unaware that I could break stuff

User avatar
TrevorH
Site Admin
Posts: 33215
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Broke my centos7 VPS when trying to update Python

Post by TrevorH » 2018/08/07 10:44:08

sudo ln -fs /usr/bin/python3 /usr/bin/python
That broke it. It should look like

lrwxrwxrwx. 1 root root 7 Apr 30 01:25 /usr/bin/python -> python2
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

water
Posts: 7
Joined: 2018/08/07 09:58:53

Re: Broke my centos7 VPS when trying to update Python

Post by water » 2018/08/07 10:54:47

TrevorH wrote:
2018/08/07 10:44:08
sudo ln -fs /usr/bin/python3 /usr/bin/python
That broke it. It should look like

lrwxrwxrwx. 1 root root 7 Apr 30 01:25 /usr/bin/python -> python2
How can I restore what I did there?

Mike_Rochefort
Posts: 215
Joined: 2016/03/16 02:34:19

Re: Broke my centos7 VPS when trying to update Python

Post by Mike_Rochefort » 2018/08/07 11:47:04

Assuming none of these commands rely on Python, you should be able to:

Code: Select all

cd /usr/bin
ln -sf python2 python
Cheer,
Mike
Solution Architect @RedHat | RHCE
Former SysAdmin @BlueSkyStudios and @Pixar
Feature animation and VFX enthusiast
--
Report CentOS Stream 8 bugs: https://da.gd/c8s-bugs
Report CentOS Stream 9 bugs: https://da.gd/c9s-bugs

water
Posts: 7
Joined: 2018/08/07 09:58:53

Re: Broke my centos7 VPS when trying to update Python

Post by water » 2018/08/07 11:54:18

Mike_Rochefort wrote:
2018/08/07 11:47:04
Assuming none of these commands rely on Python, you should be able to:

Code: Select all

cd /usr/bin
ln -sf python2 python
Cheer,
Mike
I got this as output: ln: failed to access ‘python’: Too many levels of symbolic links

Mike_Rochefort
Posts: 215
Joined: 2016/03/16 02:34:19

Re: Broke my centos7 VPS when trying to update Python

Post by Mike_Rochefort » 2018/08/07 12:33:00

Are you running as root or using sudo? If yes, try removing the symbolic link completely (rm python) then recreate it with python2.

Cheers,
Mike
Solution Architect @RedHat | RHCE
Former SysAdmin @BlueSkyStudios and @Pixar
Feature animation and VFX enthusiast
--
Report CentOS Stream 8 bugs: https://da.gd/c8s-bugs
Report CentOS Stream 9 bugs: https://da.gd/c9s-bugs

User avatar
jlehtone
Posts: 4530
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Broke my centos7 VPS when trying to update Python

Post by jlehtone » 2018/08/07 12:45:34

One would expec to see:

Code: Select all

# ls -l /usr/bin/python*
lrwxrwxrwx. 1 root root    7 Jul 23 14:51 /usr/bin/python -> python2
lrwxrwxrwx. 1 root root    9 Jul 23 14:51 /usr/bin/python2 -> python2.7
-rwxr-xr-x. 1 root root 7216 Jul 13 16:07 /usr/bin/python2.7
-rwxr-xr-x. 1 root root 1835 Jul 13 16:07 /usr/bin/python2.7-config
lrwxrwxrwx. 1 root root   16 Jul 23 14:54 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx. 1 root root   14 Jul 23 14:54 /usr/bin/python-config -> python2-config
That is,
the /usr/bin/python2.7 is a file.
The /usr/bin/python2 is a symbolic link to /usr/bin/python2.7
The /usr/bin/python is a symbolic link to /usr/bin/python2

What have you now?


Furthermore,

Code: Select all

scl enable python36u bash
Runs a command (bash) in modified environment. In that environment the "python36u"'s binaries are first on the PATH. Exit from that shell, if you haven't already.

Code: Select all

$ scl enable rh-python36 bash
$ ps af
  PID TTY      STAT   TIME COMMAND
 2040 pts/2    Ss     0:00 bash
 2448 pts/2    S      0:00  \_ scl enable rh-python36 bash
 2449 pts/2    S      0:00      \_ /bin/bash /var/tmp/sclKXjWJx
 2452 pts/2    S      0:00          \_ bash
 2543 pts/2    R+     0:00              \_ ps af
$ exit
exit
$ ps af
  PID TTY      STAT   TIME COMMAND
 2040 pts/2    Ss     0:00 bash
 3543 pts/2    R+     0:00  \_ ps af

water
Posts: 7
Joined: 2018/08/07 09:58:53

Re: Broke my centos7 VPS when trying to update Python

Post by water » 2018/08/07 13:14:12

jlehtone wrote:
2018/08/07 12:45:34
ls -l /usr/bin/python* outputs Image

And I don't know if the shell is still running actually. I rebooted the VPS already so probably the shell is already exit?

ps af gives
Image

Post Reply