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.

  • See the answer over at ServerFault: Reinstalling python on CentOS to be able to use yum – eyoung100 Sep 25 '18 at 6:44
  • How is this a duplicate? The OP clearly states he cannot use yum, as Python is a dependency, which he clearly admits he removed by accident. Reinstalling yum does not fix the missing python package, as rpm does not handle dependency resolution. Voting to reopen – eyoung100 Sep 26 '18 at 18:10
  • Did my answer help you? We all haven't heard back from you. Please let us all know. – eyoung100 Sep 28 '18 at 4:42
  • @eyoung100 ,your answer worked.Sorry that i forgot to accept the answer – theDbGuy Sep 28 '18 at 6:32
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
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

  • 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 8: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 8: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 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.