aneesh
aneesh

Reputation: 171

-bash: /usr/bin/yum: /usr/bin/python: bad interpreter: Permission denied

I am new in centos.I am try to do an application on it.For my application I need to install python 2.7.But the default one on server was python 2.6. So tried to upgrade the version .And accidentally I deleted the folder /usr/bin/python.After that I Installed python 2.7 through make install.I created the folder again /usr/bin/python and run command sudo ln -s /usr/bin/python2.7 /usr/bin/python. After this when I tried to run YUM commands I am getting the error

-bash: /usr/bin/yum: /usr/bin/python: bad interpreter: Permission denied

drwxrwxrwx 2 root root 4096 Mar 8 00:19 python

this is permission showing for the directory /usr/bin/python

Upvotes: 6

Views: 55822

Answers (6)

Resolution for CentOs 7:

dnf reinstall python-2.7.5-92.el7_9.x86_64
dnf reinstall yum 

Remove python3 first using dnf if it is installed already.

Upvotes: 0

andot
andot

Reputation: 89

this problem is that yum file start head write #!/usr/local/bin/python2.6, write binary file, is not dir, is python binary file

Upvotes: 0

Wajid Shaikh
Wajid Shaikh

Reputation: 439

It is very simple; because the Python package was removed, the yum command won't work.

Please use below link to install packages:

Go to Link and download python package

wget http://mirror.centos.org/centos/7/sclo/x86_64/rh/python27/python27-1.1-26.1.el7.x86_64.rpm
rpm -ivh python27-1.1-26.1.el7.x86_64.rpm

Then yum will work.

Upvotes: 3

SimonLau
SimonLau

Reputation: 41

yum doesn't work with python2.7. You should do the following vim /usr/bin/yum change #!/usr/bin/python to #!/usr/bin/python2.6 If your python2.6 was deleted, then reinstall them and point the directory in /usr/bin/yum to your python2.6 directory.

Upvotes: 4

vk_only
vk_only

Reputation: 39

-bash: /usr/bin/yum: /usr/bin/python: bad interpreter: Permission denied then

  1. first remove python follow command line

    -- sudo rpm -e python

  2. second check which package install this command line

    -- sudo rpm -q python

  3. then install package

    -- sudo yum install python*

    i think this problem solve

Upvotes: -1

MattDMo
MattDMo

Reputation: 102852

CentOS requires that /usr/bin/python be pointed to Python 2.6, not any other version. Run the following commands:

sudo rm -rf /usr/bin/python
sudo ln -s /usr/bin/python2.6 /usr/bin/python

to at least fix that part of it. Next time you're building Python, use the defaults and install it to /usr/local/bin, not /usr/bin. That's what the /usr/local hierarchy is for - user-installed programs. /usr and /usr/bin should only be for system-installed programs (such as those installed by yum or its graphical equivalents), and you should keep out unless you know what you're doing. To use identically-named programs in /usr/local/bin instead of their counterparts in /usr/bin, open your ~/.bashrc or ~/.bash_profile (whichever your system uses) and add the following as the last line:

export PATH=/usr/local/bin:$PATH

Restart your shell session, and you should be all set.

Upvotes: 11

Related Questions