2

I have an EC2 instance on which I was trying to install spark.I removed the required system python version from the system by mistake and nothing relying on python seems to work now including yum and other system tools.

I need to fix the broken python version in my EC2 Linux(Centos).

Below is the error I get when I try to use yum

-bash: /usr/bin/yum: /usr/bin/python2.7: bad interpreter: No such file or directory

I guess, I deleted a required version of python.

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
theDbGuy
  • 123

2 Answers2

2

Using the answer I linked in my comment, I realized that the mirror in that answer no longer exists, so:

  1. Browse to the CentOS Mirror List, if the browser is still functional.
  2. From your chosen mirror, choose your CentOS Version
  3. Follow this path: /os/x86_64/Packages. Note: x86_64 is now the default architecture. If EC2 is an older version of CentOS this may be replaced by x86.
  4. Take note of the path created in step 3, and add the appropriate python RPM file to the end. At the time of this posting, using version 7 as an example, it is python-2.7.5-68.el7.x86_64.rpm.
  5. Add the path constructed from steps three and four to the wget command. Example: wget http://yum.tamu.edu/centos/7/os/x86_64/Packages/python-2.7.5-68.el7.x86_64.rpm
  6. Use the Redhat Package Manager to install the downloaded file: rpm -ivh /path/to/downloaded/file/python-2.7.5-68.el7.x86_64.rpm
  7. For consistency sake: yum install yum python
eyoung100
  • 6,252
  • 23
  • 53
0

First download python rpm as per your kernel architecture/OS version from following url:

https://www.python.org/download/releases/2.7

or

https://centos.pkgs.org/7/centos-sclo-rh-testing/python27-python-2.7.13-5.el7.x86_64.rpm.html

Then try installing python using rpm as:

rpm -ivh package-name

Then try to install any package using yum

erTugRul
  • 516
  • I'm merely stating that the OP might replace the 4 in your reference link as you call it with a 7, since his python symbolic link is pointing to 2.7. When you do so, you end up with a 404 Error. I then added that if you follow your example, which isn't really one at all, as python is not kernel or architecture dependent, you end up on a page full of tarballs, and then I stated the fact that CentOS is very picky about versioning and packages, but terdon beat me to the punchline – eyoung100 Sep 25 '18 at 08:01
  • @terdon I understand brother. But eyoung100 is not trying to understand what point I want to make. I have edited my answer as well. – erTugRul Sep 25 '18 at 08:03
  • The first link in your edit are the tarballs I referred to. The second is half right. I remind you again: If EC2 is not CentOS 7, it is incorrect. See Step #2 in my answer. You can't blindly post a link here, as Google readers will click on anything if they think it will remotely solve their issue. That's why Step 5 is labeled as an example – eyoung100 Sep 25 '18 at 08:05